library tale-cache
A small and basic PSR-6 compatible caching library
talesoft/tale-cache
A small and basic PSR-6 compatible caching library
- Tuesday, March 1, 2016
- by TorbenKoehn
- Repository
- 3 Watchers
- 0 Stars
- 4 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 2 Versions
- 0 % Grown
Tale Cache
What is Tale Cache?
Tale Cache is a complete PSR-6 and PSR-16 implementation
that provides different cache pools and simple cache interfaces., (*1)
Installation
Don't use in production yet, (*2)
composer req talesoft/tale-cache
Usage
use function Tale\cache;
use function Tale\cache_pool_routing;
use function Tale\cache_pool_serialized_file;
use function Tale\cache_pool_redis; //Doesn't actually exist yet
$cache = cache(cache_pool_routing([
'app.' => cache_pool_serialized_file(__DIR__.'/var/cache/app'),
'db.' => cache_pool_redis('redis://localhost')
]);
$value = $cache->get('app.my_namespace.my_value');
if ($value === null) {
$value = do_some_heavy_work()
$cache->set('app.my_namespace.my_value', $value);
}
//$value is now cached to var/cache/app/my_namespace/my_value.cache
//TODO: more docs, more tests, (*3)