eoko / kes
Installs: 1 959
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- jms/serializer: ~1.10
- pimple/pimple: ~3.0
- predis/predis: ^1.1
- ramsey/uuid: ^3.7
- symfony/cache: ~3.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.8
- phpunit/phpunit: ^5.7
- squizlabs/php_codesniffer: ^2.9.0
This package is not auto-updated.
Last update: 2024-12-22 06:20:31 UTC
README
Store entity in a key/value database like Redis.
Usage
Create Manager
<?php use Doctrine\Common\Annotations\AnnotationRegistry; use Eoko\Kes\EntityCacheManager; use Eoko\Kes\Plugins\DisabledPlugin\DisabledPlugin; use Eoko\Kes\Plugins\MetadataPlugin\MetadataPlugin; use Eoko\Kes\Plugins\UniqueIdPlugin\UniqueIdPlugin; use JMS\Serializer\SerializerBuilder; use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\EventDispatcher\EventDispatcher; AnnotationRegistry::registerLoader('class_exists'); $eventDispatcher = new EventDispatcher(); $serializer = SerializerBuilder::create()->build(); $adapter = new TagAwareAdapter(new ArrayAdapter()); $manager = new EntityCacheManager($adapter); // Register some useful plugins $manager->registerPlugin(new MetadataPlugin()); $manager->registerPlugin(new UniqueIdPlugin()); $manager->registerPlugin(new DisabledPlugin());
$entity = new SampleEntity();
$manager->createOneEntity($entity);
/** @var MetadataEntityInterface|BaseEntityInterface|DisableEntityInterface $entity */ $entity = $manager->getOneEntity($entity); $manager->updateOneEntity($entity);
$entity->setDisabled(true);
$manager->updateOneEntity($entity);
$manager->getOneEntity($entity, ['ignoreDisabled' => true]);
$entity->setDisabled(false);
$manager->updateOneEntity($entity, ['ignoreDisabled' => false]);
// $manager->deleteOneEntity($entity);