PHP Class Pimcore\Cache\Backend\Mongodb

Inheritance: extends Zend_Cache_Backend, implements Zend_Cache_Backend_ExtendedInterface
Show file Open project: pimcore/pimcore

Protected Properties

Property Type Description
$_collection MongoCollection
$_conn Mongo
$_db MongoDB
$_options =====> (array) servers : an array of mongodb server ; each mongodb server is described by an associative array : 'host' => (string) : the name of the mongodb server 'port' => (int) : the port of the mongodb server 'collection' => (string) : name of the collection to use 'dbname' => (string) : name of the database to use

Public Methods

Method Description
___expire ( string $id ) : void Expires a record (mostly used for testing purposes)
__construct ( $options ) : void
clean ( string $mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = [] ) : boolean Clean some cache records (protected method used for recursive stuff)
drop ( )
get ( integer $id ) : array | false
getCapabilities ( ) : array Return an associative array of capabilities (booleans) of the backend
getFillingPercentage ( ) : integer No way to find the remaining space right now. So return 1.
getIds ( ) : array Return an array of stored cache ids
getIdsMatchingAnyTags ( array $tags = [] ) : array Return an array of stored cache ids which match any given tags
getIdsMatchingTags ( array $tags = [] ) : array Return an array of stored cache ids which match given tags
getIdsNotMatchingTags ( array $tags = [] ) : array Return an array of stored cache ids which don't match given tags
getMetadatas ( string $id ) : array Return an array of metadatas for the given cache id
getTags ( ) : array Return an array of stored tags
isAutomaticCleaningAvailable ( ) : boolean Return true if the automatic cleaning is available for the backend
load ( string $id, boolean $doNotTestCacheValidity = false ) : string | false Test if a cache is available for the given id and (if yes) return it (false else)
remove ( string $id ) : boolean Remove a cache record
save ( string $data, string $id, array $tags = [], integer $specificLifetime = false ) : boolean Save some string datas into a cache record
set ( integer $id, array $data, integer $lifetime, mixed $tags ) : boolean
setDirectives ( array $directives ) Set the frontend directives
test ( string $id ) : mixed | false Test if a cache is available or not (for the given id)
touch ( string $id, integer $extraLifetime ) : boolean Give (if possible) an extra lifetime to the given cache id

Method Details

___expire() public method

Expires a record (mostly used for testing purposes)
public ___expire ( string $id ) : void
$id string
return void

__construct() public method

public __construct ( $options ) : void
return void

clean() public method

Available modes are : \Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) \Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) \Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags ($tags can be an array of strings or a single string) \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} ($tags can be an array of strings or a single string) \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags ($tags can be an array of strings or a single string)
public clean ( string $mode = Zend_Cache::CLEANING_MODE_ALL, array $tags = [] ) : boolean
$mode string Clean mode
$tags array Array of tags
return boolean True if no problem

drop() public method

public drop ( )

get() public method

public get ( integer $id ) : array | false
$id integer
return array | false

getCapabilities() public method

The array must include these keys : - automatic_cleaning (is automating cleaning necessary) - tags (are tags supported) - expired_read (is it possible to read expired cache records (for doNotTestCacheValidity option for example)) - priority does the backend deal with priority when saving - infinite_lifetime (is infinite lifetime can work with this backend) - get_list (is it possible to get the list of cache ids and the complete list of tags)
public getCapabilities ( ) : array
return array associative of with capabilities

getFillingPercentage() public method

No way to find the remaining space right now. So return 1.
public getFillingPercentage ( ) : integer
return integer integer between 0 and 100

getIds() public method

Return an array of stored cache ids
public getIds ( ) : array
return array array of stored cache ids (string)

getIdsMatchingAnyTags() public method

In case of multiple tags, a logical AND is made between tags
public getIdsMatchingAnyTags ( array $tags = [] ) : array
$tags array array of tags
return array array of any matching cache ids (string)

getIdsMatchingTags() public method

In case of multiple tags, a logical AND is made between tags
public getIdsMatchingTags ( array $tags = [] ) : array
$tags array array of tags
return array array of matching cache ids (string)

getIdsNotMatchingTags() public method

In case of multiple tags, a logical OR is made between tags
public getIdsNotMatchingTags ( array $tags = [] ) : array
$tags array array of tags
return array array of not matching cache ids (string)

getMetadatas() public method

The array must include these keys : - expire : the expire timestamp - tags : a string array of tags - mtime : timestamp of last modification time
public getMetadatas ( string $id ) : array
$id string cache id
return array array of metadatas (false if the cache id is not found)

getTags() public method

Return an array of stored tags
public getTags ( ) : array
return array array of stored tags (string)

isAutomaticCleaningAvailable() public method

Return true if the automatic cleaning is available for the backend

load() public method

Test if a cache is available for the given id and (if yes) return it (false else)
public load ( string $id, boolean $doNotTestCacheValidity = false ) : string | false
$id string Cache id
$doNotTestCacheValidity boolean If set to true, the cache validity won't be tested
return string | false cached datas

remove() public method

Remove a cache record
public remove ( string $id ) : boolean
$id string Cache id
return boolean True if no problem

save() public method

Note : $data is always "string" (serialization is done by the core not by the backend)
public save ( string $data, string $id, array $tags = [], integer $specificLifetime = false ) : boolean
$data string Datas to cache
$id string Cache id
$tags array Array of strings, the cache record will be tagged by each string entry
$specificLifetime integer If != false, set a specific lifetime for this cache record (null => infinite lifetime)
return boolean True if no problem

set() public method

public set ( integer $id, array $data, integer $lifetime, mixed $tags ) : boolean
$id integer
$data array
$lifetime integer
$tags mixed
return boolean

setDirectives() public method

Set the frontend directives
public setDirectives ( array $directives )
$directives array Assoc of directives

test() public method

Test if a cache is available or not (for the given id)
public test ( string $id ) : mixed | false
$id string Cache id
return mixed | false (a cache is not available) or "last modified" timestamp (int) of the available cache record

touch() public method

Give (if possible) an extra lifetime to the given cache id
public touch ( string $id, integer $extraLifetime ) : boolean
$id string cache id
$extraLifetime integer
return boolean true if ok

Property Details

$_collection protected property

protected MongoCollection $_collection
return MongoCollection

$_conn protected property

protected Mongo $_conn
return Mongo

$_db protected property

protected MongoDB $_db
return MongoDB

$_options protected property

=====> (array) servers : an array of mongodb server ; each mongodb server is described by an associative array : 'host' => (string) : the name of the mongodb server 'port' => (int) : the port of the mongodb server 'collection' => (string) : name of the collection to use 'dbname' => (string) : name of the database to use
protected $_options