======== Storages ======== Storage is the persistence layer for intents and this library provides two implementations out of the box. Which one you should use depends on your project and on the guarantees which you expect from the storage. Doctrine Dbal storage --------------------- ``RunOpenCode\Component\Intent\Storage\DbalStorage`` stores intents within a single database table. Intents survive a restart of your infrastructure and they are removed only when they are fetched, invalidated, or when the storage is maintained. .. code-block:: php :linenos: `. Generating the table ~~~~~~~~~~~~~~~~~~~~ If you are using Doctrine ORM, storage is able to contribute its table to the schema which ORM generates for your entities. Register it as a listener for the ``postGenerateSchema`` event and the table will be created for you along with the rest of your schema: .. code-block:: php :linenos: getEventManager() ->addEventListener([ToolEvents::postGenerateSchema], $storage); Storage will contribute its table only if the schema is generated for the very same connection which is used for storing intents, which makes it safe to use within projects having more than one entity manager. If you are using Symfony framework, this is done for you, see the :doc:`Intent Bundle documentation <../../bundles/intent-bundle/index>`. Cache storage ------------- ``RunOpenCode\Component\Intent\Storage\CacheStorage`` stores intents within any PSR-6 cache pool, which makes Redis, Memcached, filesystem, or any other cache implementation available to you without any additional code: .. code-block:: php :linenos: