Download the PHP package omnilog/psr6-dynamo-db-bundle without Composer
On this page you can find all versions of the php package omnilog/psr6-dynamo-db-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download omnilog/psr6-dynamo-db-bundle
More information about omnilog/psr6-dynamo-db-bundle
Files in omnilog/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.
Installation
composer require omnilog/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)version
- the service version (default: latest)- 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 (
omnilog.dynamo_cache.encoder.serialize
,omnilog.dynamo_cache.encoder.json
) - can be a custom service implementing the
\Omnilog\DynamoDbCache\Encoder\CacheItemEncoderInterface
interface - default value: omnilog.dynamo_cache.encoder.serialize
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 omnilog_dynamo_db_cache
):
Usage
You can use one of the two available services:
Omnilog\DynamoDbCache\DynamoDbCache
- this one doesn't implement the SymfonyAdapterInterface
norCacheInterface
Omnilog\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 \Omnilog\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
omnilog.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.
All versions of psr6-dynamo-db-bundle with dependencies
omnilog/psr6-dynamo-db Version 0.0.1
php Version ^7.2 | ^8.0
symfony/cache Version ^4.4|^5.0