Download the PHP package rikudou/psr6-dynamo-db-bundle without Composer
On this page you can find all versions of the php package rikudou/psr6-dynamo-db-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rikudou/psr6-dynamo-db-bundle
More information about rikudou/psr6-dynamo-db-bundle
Files in rikudou/psr6-dynamo-db-bundle
Package psr6-dynamo-db-bundle
Short Description PSR-6 and PSR-16 cache implementation using AWS DynamoDB for Symfony
License MIT
Informations about the package psr6-dynamo-db-bundle
Don't use Symfony? Use the standalone library.
Since version 2 this library uses the lightweight async-aws/dynamo-db instead of the full AWS SDK.
Installation
composer require rikudou/psr6-dynamo-db-bundle
Configuration
Create the file config/packages/dynamo_db_cache.yaml
and put at least the table name there:
Everything else has default values, though you probably want to also configure the dynamo db client.
Configuration options:
replace_default_adapter
- set totrue
to replace the defaultAdapterInterface
andCacheInterface
implementation with the adapter from this bundle (default: false)table
- the table which will be used for storing the cache (required)client_service
- The service that will be used as DynamoDB client, if not set this bundle will try to create one (more details inclient_config
option below) but the use is limitedclient_config
- If noclient_service
is configured, it will be created from the values of this config. It contains two subkeys:region
- the AWS region (default: us-east-1)- no other options are available, if you need to configure more, please create and assign custom
client_service
encoder
- contains the settings for encoders:service
- the service which will be used as the encoder- can be one of built-in services (
rikudou.dynamo_cache.encoder.serialize
,rikudou.dynamo_cache.encoder.json
) - can be a custom service implementing the
\Rikudou\DynamoDbCache\Encoder\CacheItemEncoderInterface
interface - default value: rikudou.dynamo_cache.encoder.serialize
- can be one of built-in services (
json_options
- settings for the json encoder, ignored if another encoder is usedencode_flags
- the same flags you would pass tojson_encode()
decode_flags
- the same flags you would pass tojson_decode()
depth
- the depth argument for bothjson_encode()
andjson_decode()
primary_key_field
- the name of the field that will be used as the primary key (default: id)ttl_field
- the name of the field that will be used as the ttl field (default: ttl)value_field
- the name of the field that will be used as the value field (default: value)key_prefix
- the prefix used in front of the item keys (default: null which means none)
Autogenerated default config (via bin/console config:dump rikudou_dynamo_db_cache
):
Usage
You can use one of the two available services:
Rikudou\DynamoDbCache\DynamoDbCache
- this one doesn't implement the SymfonyAdapterInterface
norCacheInterface
Rikudou\DynamoDbCacheBundle\Cache\DynamoDbCacheAdapter
- this one implements the SymfonyAdapterInterface
andCacheInterface
If you set the replace_default_adapter
to true
you can also use these interfaces as services:
Symfony\Component\Cache\Adapter\AdapterInterface
- the Symfony interface for PSR-6 cacheSymfony\Contracts\Cache\CacheInterface
- the Symfony interface for simple cachePsr\Cache\CacheItemPoolInterface
- the PSR-6 interfacePsr\SimpleCache\CacheInterface
- the PSR-16 interface
Example
While using the replace_default_adapter
option:
Or using the PSR interfaces:
Converters
This bundle supports all instances of \Psr\Cache\CacheItemInterface
with the use of converters which
convert the object to \Rikudou\DynamoDbCache\DynamoCacheItem
. Note that some information may be lost in the
conversion, notably expiration date.
This bundle has a handler for the default Symfony \Symfony\Component\Cache\CacheItem
where it retains also the
information about expiration date.
If you use any other CacheItemInterface
implementation, you may need to write your custom handler:
Your converter is now automatically registered in the converter system and will be used whenever you try to save
an instance of MyCacheItem
.
If you don't use autoconfiguration, tag your service with
rikudou.dynamo_cache.converter
The default converter which will be used as last option can convert all CacheItemInterface
objects but has no
way to get the expiration date since the interface doesn't provide such information.
Session
This bundle contains a session handler to store your session data in DynamoDB.
To use it you either need to specify the handler_id
in framework.yaml
to rikudou.dynamo_cache.session
or set replace_default_adapter
to true
and remove handler_id
from framework.yaml
(the default configuration created by flex specifies null
explicitly as the handler_id
, if you want to use the
replace_default_adapter
, remove it from the config).
All versions of psr6-dynamo-db-bundle with dependencies
rikudou/psr6-dynamo-db Version ^3.1
php Version ^8.0
symfony/cache Version ^6.0 || ^7.0
ext-json Version *