mirror of
https://github.com/danog/Valinor.git
synced 2024-12-03 10:07:48 +01:00
69ad3f4777
The cache implementation that was previously injected in the mapper builder must now be manually injected. This gives better control on when the cache should be enabled, especially depending on which environment the application is running. The library provides a cache implementation out of the box, which saves cache entries into the file system. It is also possible to use any PSR-16 compliant implementation, as long as it is capable of caching the entries handled by the library. ```php $cache = new \CuyZ\Valinor\Cache\FileSystemCache('path/to/cache-dir'); (new \CuyZ\Valinor\MapperBuilder()) ->withCache($cache) ->mapper() ->map(SomeClass::class, [/* … */]); ```
44 lines
960 B
PHP
44 lines
960 B
PHP
<?php
|
|
|
|
namespace Psr\SimpleCache;
|
|
|
|
use DateInterval;
|
|
|
|
/**
|
|
* @template EntryType
|
|
*/
|
|
interface CacheInterface
|
|
{
|
|
/**
|
|
* @param string $key
|
|
* @param EntryType|null $default
|
|
* @return EntryType|null
|
|
*/
|
|
public function get(string $key, $default = null);
|
|
|
|
/**
|
|
* @param string $key
|
|
* @param EntryType $value
|
|
* @param null|int|DateInterval $ttl
|
|
*/
|
|
public function set(string $key, $value, $ttl = null): bool;
|
|
|
|
/**
|
|
* @param iterable<string> $keys
|
|
* @param EntryType $default
|
|
* @return iterable<string, EntryType|null>
|
|
*/
|
|
public function getMultiple(iterable $keys, $default = null): iterable;
|
|
|
|
/**
|
|
* @param iterable<string, EntryType> $values
|
|
* @param null|int|DateInterval $ttl
|
|
*/
|
|
public function setMultiple(iterable $values, $ttl = null): bool;
|
|
|
|
/**
|
|
* @param iterable<string> $keys
|
|
*/
|
|
public function deleteMultiple(iterable $keys): bool;
|
|
}
|