jCache

Global caching data provided from whatever sources

package

jelix

subpackage

cache

since 1.2

Methods

verify the key for a specific data : only a subset of characters are accepted : letters, numbers, '_','/',':','.','-','@','#','&'.

_checkKey(string $key) 
static

no space.

db, redis: any characters memcache: no space, no control char (\t \n \00) file: any (key is hashed with md5)

Throws
\jException

Arguments

$key

string

key used for storing data

check and call a specified method/function

_doFunctionCall(mixed $fn, array $fnargs) : mixed
static
Throws
\jException

Arguments

$fn

mixed

method/function name

$fnargs

array

arguments used by the method/function

Response

mixed

$data method/function result

get the method/function full name

_functionToString(mixed $fn) : string
static

Arguments

$fn

mixed

method/function name

Response

string

$fnname method/function name

callback method for jProfiles. internal use.

_loadDriver( $profile) 
static

Arguments

$profile

add data in the cache

add(string $key, mixed $value, mixed $ttl = null, string $profile = '') : boolean
static
Throws
\jException

Arguments

$key

string

key used for storing data in the cache

$value

mixed

data to add

$ttl

mixed

data time expiration. 0 means no expire, use a timestamp UNIX or a delay in secondes which mustn't exceed 30 days i.e 2592000s or a string in date format US

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

call a specified method/function or get the result from cache. The function must not return false. The result of the function is stored into the cache system, with the function name and other things as key. If the key already exists in the cache, the function is not called and the value is returned directly.

call(mixed $fn, array $fnargs = array(), mixed $ttl = null, string $profile = '') : mixed
static
Throws
\jException

Arguments

$fn

mixed

method/function name ($functionName or array($object, $methodName) or array($className, $staticMethodName))

$fnargs

array

arguments used by the method/function

$ttl

mixed

data time expiration. 0 means no expire, use a timestamp UNIX or a delay in secondes which mustn't exceed 30 days i.e 2592000s or a string in date format US

$profile

string

the cache profile name to use. if empty, use the default profile

Response

mixed

method/function result

decrement a specific data value by $decvalue

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

Arguments

$key

string

key used for storing data in the cache

$decvalue

mixed

value used

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

delete a specific data in the cache

delete(string $key, string $profile = '') : boolean
static

Arguments

$key

string

key used for storing data in the cache

$profile

string

the cache profil name to use. if empty, use the default profile

Response

boolean

false if failure

clear data in the cache

flush(string $profile = '') : boolean
static

Arguments

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

remove from the cache data of which TTL was expired

garbage(string $profile = '') : boolean
static

Arguments

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

retrieve data in the cache

get(mixed $key, string $profile = '') : mixed
static

Arguments

$key

mixed

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

$profile

string

the cache profile name to use. if empty, use the default profile

Response

mixed

$data data stored

load the cache driver

getDriver(string $profile) : \jICacheDriver
static

get an instance of driver according the settings in the profile file

Arguments

$profile

string

profile name

Response

\jICacheDriver

increment a specific data value by $incvalue

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

Arguments

$key

string

key used for storing data in the cache

$incvalue

mixed

value used

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

normalizeKey

normalizeKey( $key) 
static

Arguments

$key

replace a specific data value by $value

replace(string $key, mixed $value, mixed $ttl = null, string $profile = '') : boolean
static
Throws
\jException

Arguments

$key

string

key used for storing data in the cache

$value

mixed

data to replace

$ttl

mixed

data time expiration. 0 means no expire, use a timestamp UNIX or a delay in secondes which mustn't exceed 30 days i.e 2592000s or a string in date format US

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure

set a specific data in the cache

set(string $key, mixed $value, mixed $ttl = null, string $profile = '') : boolean
static
Throws
\jException

Arguments

$key

string

key used for storing data

$value

mixed

data to store

$ttl

mixed

data time expiration. 0 means no expire, use a timestamp UNIX or a delay in secondes which mustn't exceed 30 days i.e 2592000s or a string in date format US

$profile

string

the cache profile name to use. if empty, use the default profile

Response

boolean

false if failure