maslosoft / cache
Easy to use, auto configurable, extensible cache provider
Installs: 5 077
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=7.4
- maslosoft/embedi: ^1|^2|^3
Requires (Dev)
Suggests
- ext-apcu: Use APCu as cache
- ext-memcached: Use Memcached as cache
README
Maslosoft Cache
Easy to use, auto configurable, extensible cache provider
Quick Install
composer require maslosoft/cache
Documentation
Self configuring cache
This cache library provides consistent interface for popular cache systems. It uses best cache provider available based on configurable list.
Also provides logic-less getting of cache value, with fallback to callable.
Easy to use, auto configurable, extensible cache provider
If you need some modern cache with just basic features here it is.
It implements only basic cache operations:
- has - to check if has key in cache
- get - to get cached value by key
- set - to set value to cache
- remove - to remove cached value
- clear - to clear entira cache
Requirements
- PHP 5.6+
- composer
Setup
Use composer to install extension:
composer require maslosoft/cache:"*"
Setup cache. After calling init
any further instance will be configured same as below $cache
.
use Maslosoft\Cache\Cache;
$cache = new Cache();
// Setup something here...
$cache->timeout = 1244;
$cache->init();
Basic Usage
<?php
use Maslosoft\Cache\Cache;
$cache = new Cache();
// Init configuration, now it is available anywhere
// By default it will try some cache providers and select best available.
$cache->init();
$key = 1;
if(!$cache->has($key))
{
$cache->set($key, 'Some value');
}
echo $cache->get($key);
And that's it!