dtkahl / php-simple-redis-cache
Installs: 242
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 1
pkg:composer/dtkahl/php-simple-redis-cache
Requires
- php: >=5.6.0
- predis/predis: ^1.1
Requires (Dev)
- phpunit/phpunit: 5.2.*
This package is auto-updated.
Last update: 2025-09-29 01:57:52 UTC
README
PHP simple redis cache
This is a simple cache class for PHP using redis trough predis/predis.
Dependencies
PHP >= 5.6.0- a redis server
Installation
Install with Composer:
composer require dtkahl/php-simple-redis-cache
Usage
Refer namespace:
use Dtkahl\SimpleRedisCache;
Create new Cache instance:
$cache = new Cache([ "scheme" => "tcp", "host => "127.0.0.1", "port" => 6379 );
Methods
put($key, $value, $time = null)
Put item to cache. (time in seconds)
$cache->put('foo', 'bar', 60)
has($key)
Determinate if key exists in cache.
$cache->has('foo')
get($key, $default = null)
Return Item from cache or $default.
$cache->get('foo', 'default')
forget($key)
Remove item from cache.
$cache->forget('foo')
forever($key, $value)
Store item in cache forever.
$cache->forever('foo', 'bar')
remember($key, $callback, $time = null)
Return cache item if exists otherwise call $callback, cache the returned value and return it.
$cache->put('foo')