eoko/kes

There is no license information available for the latest version (1.0.1) of this package.

1.0.1 2018-03-27 12:32 UTC

This package is not auto-updated.

Last update: 2024-12-22 06:20:31 UTC


README

Build Status

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);