rcube_cache_shared

Interface class for accessing Roundcube shared cache

package

Framework

subpackage

Cache

author

Thomas Bruederli

author

Aleksander Machniak

Methods

Object constructor.

__construct(string $type, string $prefix = '', string $ttl, bool $packed = true) 

Arguments

$type

string

Engine type ('db' or 'memcache' or 'apc')

$prefix

string

Key name prefix

$ttl

string

Expiration time of memcache/apc items

$packed

bool

Enables/disabled data serialization.

                  It's possible to disable data serialization if you're sure
                  stored data will be always a safe string

Returns cached value.

get(string $key) : mixed

Arguments

$key

string

Cache key name

Response

mixed

Cached value

Sets (add/update) value in cache.

set(string $key, mixed $data) 

Arguments

$key

string

Cache key name

$data

mixed

Cache data

Returns cached value without storing it in internal memory.

read(string $key) : mixed

Arguments

$key

string

Cache key name

Response

mixed

Cached value

Sets (add/update) value in cache and immediately saves it in the backend, no internal memory will be used.

write(string $key, mixed $data) 

Arguments

$key

string

Cache key name

$data

mixed

Cache data

Clears the cache.

remove(string $key = null, boolean $prefix_mode = false) 

Arguments

$key

string

Cache key name or pattern

$prefix_mode

boolean

Enable it to clear all keys starting

                        with prefix specified in $key

Remove cache records older than ttl

expunge() 

Remove expired records of all caches

gc() 
static

Writes the cache back to the DB.

close() 

Reads cache entry.

read_record(string $key, boolean $nostore = false) : mixed

Arguments

$key

string

Cache key name

$nostore

boolean

Enable to skip in-memory store

Response

mixed

Cached value

Writes single cache record into DB.

write_record(string $key, \mxied $data) 

Arguments

$key

string

Cache key name

$data

\mxied

Serialized cache data

Deletes the cache record(s).

remove_record(string $key = null, boolean $prefix_mode = false) 

Arguments

$key

string

Cache key name or pattern

$prefix_mode

boolean

Enable it to clear all keys starting

                        with prefix specified in $key

Adds entry into memcache/apc DB.

add_record(string $key, \mxied $data, \bollean $index = false) 

Arguments

$key

string

Cache key name

$data

\mxied

Serialized cache data

$index

\bollean

Enables immediate index update

Deletes entry from memcache/apc DB.

delete_record($key, $index = true) 

Arguments

$key

$index

Writes the index entry into memcache/apc DB.

write_index() 

Gets the index entry from memcache/apc DB.

load_index() 

Creates cache key name (for memcache and apc)

ckey(string $key) : string

Arguments

$key

string

Cache key name

Response

string

Cache key

Creates index cache key name (for memcache and apc)

ikey() : string

Response

string

Cache key

Serializes data for storing

serialize($data) 

Arguments

$data

Unserializes serialized data

unserialize($data) 

Arguments

$data

Properties

Instance of database handler

db : \rcube_db|\Memcache|bool
var

Type(s)

\rcube_db|\Memcache|bool

type

type : 

prefix

prefix : 

ttl

ttl : 

packed

packed : 

index

index : 

table

table : 

cache

cache : 

cache_changes

cache_changes : 

cache_sums

cache_sums :