Documentation

Horde_Cache_Storage_Mongo extends Horde_Cache_Storage_Base
in package

Cache storage in a MongoDB database.

Tags
author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2013-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Table of Contents

CID  = 'cid'
DATA  = 'data'
EXPIRE  = 'expire'
TIMESTAMP  = 'ts'
$_db  : MongoCollection
The MongoDB Collection object for the cache data.
$_logger  : Horde_Log_Logger
Logger.
$_params  : array<string|int, mixed>
Parameters.
__construct()  : mixed
Constructor.
__destruct()  : mixed
Destructor.
__serialize()  : array<string|int, mixed>
__unserialize()  : void
clear()  : mixed
Clears all data from the cache.
exists()  : bool
Checks if a given key exists in the cache, valid for the given lifetime.
expire()  : bool
Expire any existing data for the given key.
get()  : mixed
Retrieve cached data.
serialize()  : mixed
set()  : mixed
Store an object in the cache.
setLogger()  : mixed
Set the logging object.
unserialize()  : mixed
_getCid()  : string
Gets the cache ID for a key.
_initOb()  : mixed
Do initialization tasks.

Constants

CID

public mixed CID = 'cid'

DATA

public mixed DATA = 'data'

EXPIRE

public mixed EXPIRE = 'expire'

TIMESTAMP

public mixed TIMESTAMP = 'ts'

Properties

$_db

The MongoDB Collection object for the cache data.

protected MongoCollection $_db

$_logger

Logger.

protected Horde_Log_Logger $_logger

$_params

Parameters.

protected array<string|int, mixed> $_params = array()

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

Parameters:

  - collection: (string) The collection name.
  - mongo_db: [REQUIRED] (Horde_Mongo_Client) A MongoDB client object.
Return values
mixed

__destruct()

Destructor.

public __destruct() : mixed
Return values
mixed

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

clear()

Clears all data from the cache.

public clear() : mixed
Return values
mixed

exists()

Checks if a given key exists in the cache, valid for the given lifetime.

public exists(mixed $key, mixed $lifetime) : bool
Parameters
$key : mixed

Cache key to check.

$lifetime : mixed

Lifetime of the key in seconds.

Return values
bool

Existence.

expire()

Expire any existing data for the given key.

public expire(mixed $key) : bool
Parameters
$key : mixed

Cache key to expire.

Return values
bool

Success or failure.

get()

Retrieve cached data.

public get(mixed $key, mixed $lifetime) : mixed
Parameters
$key : mixed

Object ID to query.

$lifetime : mixed

Lifetime of the object in seconds.

Return values
mixed

Cached data, or false if none was found.

serialize()

public serialize() : mixed
Return values
mixed

set()

Store an object in the cache.

public set(mixed $key, mixed $data, mixed $lifetime) : mixed
Parameters
$key : mixed

Object ID used as the caching key.

$data : mixed

Data to store in the cache.

$lifetime : mixed

Object lifetime - i.e. the time before the data becomes available for garbage collection. If 0 will not be GC'd.

Return values
mixed

setLogger()

Set the logging object.

public setLogger(Horde_Log_Logger $logger) : mixed
Parameters
$logger : Horde_Log_Logger

Log object.

Return values
mixed

unserialize()

public unserialize(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

_getCid()

Gets the cache ID for a key.

protected _getCid(string $key) : string
Parameters
$key : string

The key.

Return values
string

The cache ID.

_initOb()

Do initialization tasks.

protected _initOb() : mixed
Return values
mixed

Search results