matthieuwerner/dynamodb-storable
Composer 安装命令:
composer create-project matthieuwerner/dynamodb-storable
包简介
This component, based on the Symfony serializer and async-aws, is a human-readable andquick abstraction to easily store serialized objects in DynamoDB.
关键字:
README 文档
README
DynamoDB Storable
This component, based on the Symfony serializer and async-aws, is a human-readable and quick abstraction to easily store serialized objects in DynamoDB 🚀.
This storage use an existing DynamoDB table and create entries with
the following structure :
{"key", "namespace", "value", "class", "date""}.
Installation
composer require matthieuwerner/dynamodb-storable
Usage
Adding service
Option 1: auto wiring (Symfony/Laravel)
use Storable\Storage; protected function anyAction(Storage $storage): string { $storage->set('key', 'value'); // ... }
Option 2: instantiate class
use Storable\Storage; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; use Symfony\Component\Serializer\Serializer; protected function anyAction(): string { $encoders = [new JsonEncoder()]; $normalizers = [new ObjectNormalizer()]; $storage = new Storage($dynamoDbClientMock, new Serializer($normalizers, $encoders)); $storage->set('key', 'value'); // ... }
Write
// String $storage->set('key', 'value'); // Object $myObject = new MyObject(); $storage->setObject($myObject);
/!\ Working with objects need that they implement "StorableInterface"
Read
// String $storage->get('key'); // Return a string // Object $storage->get($objectId); // Return an object
Remove
$storage->remove('key');
Working with namespaces
// Get all objects in a namespace $storage->getByNamespace('namespace'); // Remove all objects in a namespace $storage->removeNamespace('namespace');
Changing default values
// Change the default table name (default is "storage") $storage->setTable('newTableName'); // Change the default namespace (default is "main") $storage->setNamespace('newNamespaceName'); // Change the default attribute "key" in the table structure $storage->setAttributeKey('newKeyAttribute'); // Change the default attribute "namespace" in the table structure $storage->setAttributeNamespace('newNamespaceAttribute'); // Change the default attribute "value" in the table structure $storage->setAttributeValue('newValueAttribute'); // Change the default attribute "class" in the table structure $storage->setAttributeClass('newClassAttribute'); // Change the default attribute "date" in the table structure $storage->setAttributeDate('newDateAttribute');
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-19