redis_phpCacheDriver

Implements \jICacheDriver

package

jelix

subpackage

cache_plugin

author

Yannick Le Guédart

contributor

Laurent Jouanneau

copyright

2009 Yannick Le Guédart, 2010-2016 Laurent Jouanneau

link

http://www.jelix.org

licence

http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file

Methods

constructor

__construct(array $params) 

Arguments

$params

array

driver parameters, written in the ini file

decrement a specific data value by $var

decrement(string $key, mixed $decvalue = 1) : boolean

Arguments

$key

string

key used for storing data in the cache

$decvalue

mixed

value used

Response

boolean

false if failure

delete a specific data in the cache

delete(string $key) : boolean

Arguments

$key

string

key used for storing data in the cache

Response

boolean

false if failure

esc

esc( $val) 

Arguments

$val

clear all data in the cache.

flush() : boolean

If key_prefix is set, only keys with that prefix will be removed. Note that in that case, it can result in a huge performance issue. See key_prefix_flush_method to configure the best method for your app and your server.

Response

boolean

false if failure

remove from the cache data of which TTL was expired element with TTL expired already removed => Nothing to do because redis has an internal garbage mechanism

garbage() : boolean

Response

boolean

read a specific data in the cache.

get(mixed $key) : mixed

Arguments

$key

mixed

key or array of keys used for storing data in the cache

Response

mixed

$data array of data or false if failure

Returns the redis api

getRedis() : \PhpRedis\Redis

Response

\PhpRedis\Redis

getUsedKey

getUsedKey( $key) 

Arguments

$key

increment a specific data value by $var

increment(string $key, mixed $incvalue = 1) : boolean

Arguments

$key

string

key used for storing data in the cache

$incvalue

mixed

value used

Response

boolean

false if failure

replace a specific data value by $var

replace(string $key, mixed $var, integer $ttl) : boolean

Arguments

$key

string

key used for storing data in the cache

$var

mixed

data to replace

$ttl

integer

data time expiration

Response

boolean

false if failure

set a specific data in the cache

set(string $key, mixed $value, integer $ttl) : boolean

Arguments

$key

string

key used for storing data

$value

mixed

data to store

$ttl

integer

data time expiration

Response

boolean

false if failure

unesc

unesc( $val) 

Arguments

$val

Properties

profil name used in the ini file

profileName : string
var
access

public

Type(s)

string

active cache ?

enabled : boolean
var
access

public

Type(s)

boolean

TTL used

ttl : boolean
var
access

public

Type(s)

boolean

automatic cleaning process 0 means disabled, 1 means systematic cache cleaning of expired data (at each set or add call), greater values mean less frequent cleaning

automatic_cleaning_factor : integer
var
access

public

Type(s)

integer

Key prefix to be added

key_prefix : string
var
access

protected

Type(s)

string

method to flush the keys when key_prefix is used

key_prefix_flush_method : 

direct: uses SCAN and DEL, but it can take huge time jcacheredisworker: it stores the keys prefix to delete into a redis list named 'jcacheredisdelkeys'. You can use a script to launch a worker which pops from this list prefix of keys to delete, and delete them with SCAN/DEL redis commands. See the redisworker controller in the jelix module. event: send a jEvent. It's up to your application to respond to this event and to implement your prefered method to delete all keys.

Type(s)

redis

redis : 
param

the redis connection

Type(s)