Download the PHP package mireiawen/cache without Composer
On this page you can find all versions of the php package mireiawen/cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mireiawen/cache
More information about mireiawen/cache
Files in mireiawen/cache
Package cache
Short Description A wrapper for the PhpFastCache caching backend
License MIT
Informations about the package cache
Cache
A wrapper for PhpFastCache caching backend, using its PSR-16 implementation. This wrapper supports some of the more common drivers, as well as has the methods to read, write, delete and check for keys in the backend.
- Class:
Cache
- Namespace:
Mireiawen\Cache
Requirements
- Cache backend
- PHP7
Installation
You can clone or download the code from the GitHub repository or you can use composer: composer require mireiawen/cache
Methods
__construct
Cache::__construct(string $driver, array $config = [])
Set up the caching backend driver
Arguments
- string
$driver
- The cache backend driver to use, currently supported are:- files
- memcache
- memcached
- redis
- predis
- array
$config
- The backend specific configuration optionsfiles
:path
- The filesystem path where to store the cached datamemcache
,memcached
:host
- The hostname to connect to, defaults tolocalhost
port
- The port to connect to, defaults to11211
redis
,predis
:host
- The hostname to connect to, defaults tolocalhost
port
- The port to connect to, defaults to6379
password
- The password to connect with, defaults toNULL
database
- The database to use, defaults toNULL
Exceptions thrown
PhpfastcacheDriverCheckException
- On Driver errors
PhpfastcacheLogicException
- On PhpFastCache logic errors
\Exception
- In case of configuration errors
Available
Cache::Available(string $id)
Check if the key exists in the cache backend
Arguments
- string
$id
- The cache ID to check for
Return value
- bool - TRUE if $id is cached, FALSE otherwise
Exceptions thrown
PhpfastcacheSimpleCacheException
- On cache errors
Invalidate
Cache::Invalidate(string $id)
Invalidate or delete the key from the cache backend
Arguments
- string
$id
- The cache ID to invalidate
Exceptions thrown
PhpfastcacheSimpleCacheException
- On cache errors
Write
Cache::Write(string $id, mixed $value, int $ttl)
Store a value to the cache backend
Arguments
- string
$id
- The cache ID to store to - mixed
$value
- The value to store to the cache - int
$ttl
- The time to live for the cached item
Exceptions thrown
PhpfastcacheSimpleCacheException
- On cache errors
Read
Cache::Read(string $id)
Retrieve a stored value from the cache backend
Arguments
- string
$id
- The cache ID to read from
Return value
- mixed - The stored value of the key
Exceptions thrown
PhpfastcacheSimpleCacheException
- On cache errors