-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
composer require j0sh0nat0r/simple-cache
(make sure to include autoload.php!)
use J0sh0nat0r\SimpleCache\Cache
use J0sh0nat0r\SimpleCache\Drivers\APC
$cache = new Cache(APC::class)
$cache->store('foo', 'bar')
The cache now contains an item with the key foo and the value bar.
Because we didn't pass a third argument (time) this value will expire in 1 hour
$cache->store(['foo' => 'bar'])
The same as standard syntax, but in this case we passed an array of key-value pairs
$foo = $cache->get('foo')
$foo Will now contain the value bar (provided you followed all previous steps)
$baz = $cache->get(['foo'])'
$baz Is now an array of values, keyed in the same fashion as the cache.
In this case $baz['foo'] will contain bar
$cache->remove('foo')
The cache no-longer contains the item with the key foo
$cache->remove(['foo'])
The same as standard syntax, but in this case we passed an array of keys to remove
$cache->clear()
The cache is now empty