Horde_Imap_Client_Cache_Backend_Mongo
extends Horde_Imap_Client_Cache_Backend
in package
implements
Horde_Mongo_Collection_Index
A MongoDB database implementation for caching IMAP/POP data.
Requires the Horde_Mongo class.
Tags
Interfaces, Classes, Traits and Enums
- Horde_Mongo_Collection_Index
Table of Contents
- BASE = 'horde_imap_client_cache_data'
- Mongo collection names.
- BASE_HOSTSPEC = 'hostspec'
- Mongo field names: BASE collection.
- BASE_MAILBOX = 'mailbox'
- BASE_MODIFIED = 'modified'
- BASE_PORT = 'port'
- BASE_UID = 'data'
- BASE_USERNAME = 'username'
- MD = 'horde_imap_client_cache_metadata'
- MD_DATA = 'data'
- Mongo field names: MD collection.
- MD_FIELD = 'field'
- MD_UID = 'uid'
- MSG = 'horde_imap_client_cache_message'
- MSG_DATA = 'data'
- Mongo field names: MSG collection.
- MSG_MSGUID = 'msguid'
- MSG_UID = 'uid'
- $_db : MongoDB
- The MongoDB object for the cache data.
- $_indices : array<string|int, mixed>
- The list of indices.
- $_params : array<string|int, mixed>
- Configuration paramters.
- __construct() : mixed
- Constructor.
- __serialize() : array<string|int, mixed>
- __unserialize() : mixed
- checkMongoIndices() : mixed
- clear() : mixed
- Clear the cache.
- createMongoIndices() : mixed
- deleteMailbox() : mixed
- Delete a mailbox from the cache.
- deleteMsgs() : mixed
- Delete messages in the cache.
- get() : array<string|int, mixed>
- Get information from the cache for a set of UIDs.
- getCachedUids() : array<string|int, mixed>
- Get the list of cached UIDs.
- getMetaData() : array<string|int, mixed>
- Get metadata information for a mailbox.
- serialize() : mixed
- set() : mixed
- Store data in cache.
- setMetaData() : mixed
- Set metadata information for a mailbox.
- setParams() : mixed
- Add configuration parameters.
- unserialize() : mixed
- _createUid() : string
- Create and return the UID for a mailbox/user/server combo.
- _getUid() : string
- Return the UID for a mailbox/user/server combo.
- _initOb() : mixed
- Initialization tasks.
- _value() : mixed|MongoBinData
- Convert data from/to storage format.
Constants
BASE
Mongo collection names.
public
mixed
BASE
= 'horde_imap_client_cache_data'
BASE_HOSTSPEC
Mongo field names: BASE collection.
public
mixed
BASE_HOSTSPEC
= 'hostspec'
BASE_MAILBOX
public
mixed
BASE_MAILBOX
= 'mailbox'
BASE_MODIFIED
public
mixed
BASE_MODIFIED
= 'modified'
BASE_PORT
public
mixed
BASE_PORT
= 'port'
BASE_UID
public
mixed
BASE_UID
= 'data'
BASE_USERNAME
public
mixed
BASE_USERNAME
= 'username'
MD
public
mixed
MD
= 'horde_imap_client_cache_metadata'
MD_DATA
Mongo field names: MD collection.
public
mixed
MD_DATA
= 'data'
MD_FIELD
public
mixed
MD_FIELD
= 'field'
MD_UID
public
mixed
MD_UID
= 'uid'
MSG
public
mixed
MSG
= 'horde_imap_client_cache_message'
MSG_DATA
Mongo field names: MSG collection.
public
mixed
MSG_DATA
= 'data'
MSG_MSGUID
public
mixed
MSG_MSGUID
= 'msguid'
MSG_UID
public
mixed
MSG_UID
= 'uid'
Properties
$_db
The MongoDB object for the cache data.
protected
MongoDB
$_db
$_indices
The list of indices.
protected
array<string|int, mixed>
$_indices
= array(self::BASE => array('base_index_1' => array(self::BASE_HOSTSPEC => 1, self::BASE_MAILBOX => 1, self::BASE_PORT => 1, self::BASE_USERNAME => 1)), self::MSG => array('msg_index_1' => array(self::MSG_MSGUID => 1, self::MSG_UID => 1)))
$_params
Configuration paramters.
protected
array<string|int, mixed>
$_params
= array()
Values set by the base Cache object: hostspec, port, username
Methods
__construct()
Constructor.
public
__construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
- $params : array<string|int, mixed> = array()
-
Configuration parameters:
- REQUIRED parameters: - mongo_db: (Horde_Mongo_Client) A MongoDB client object.
Return values
mixed —__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —__unserialize()
public
__unserialize(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —checkMongoIndices()
public
checkMongoIndices() : mixed
Return values
mixed —clear()
Clear the cache.
public
clear(mixed $lifetime) : mixed
Parameters
- $lifetime : mixed
-
Only delete entries older than this (in seconds). If null, deletes all entries.
Return values
mixed —createMongoIndices()
public
createMongoIndices() : mixed
Return values
mixed —deleteMailbox()
Delete a mailbox from the cache.
public
deleteMailbox(mixed $mailbox) : mixed
Parameters
- $mailbox : mixed
-
The mailbox to delete.
Return values
mixed —deleteMsgs()
Delete messages in the cache.
public
deleteMsgs(mixed $mailbox, mixed $uids) : mixed
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $uids : mixed
-
The list of message UIDs to delete.
Return values
mixed —get()
Get information from the cache for a set of UIDs.
public
get(mixed $mailbox, mixed $uids, mixed $fields, mixed $uidvalid) : array<string|int, mixed>
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $uids : mixed
-
The list of message UIDs to retrieve information for.
- $fields : mixed
-
An array of fields to retrieve. If empty, returns all cached fields.
- $uidvalid : mixed
-
The IMAP uidvalidity value of the mailbox.
Return values
array<string|int, mixed> —An array of arrays with the UID of the message as the key (if found) and the fields as values (will be undefined if not found).
getCachedUids()
Get the list of cached UIDs.
public
getCachedUids(mixed $mailbox, mixed $uidvalid) : array<string|int, mixed>
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $uidvalid : mixed
-
The IMAP uidvalidity value of the mailbox.
Return values
array<string|int, mixed> —The (unsorted) list of cached UIDs.
getMetaData()
Get metadata information for a mailbox.
public
getMetaData(mixed $mailbox, mixed $uidvalid, mixed $entries) : array<string|int, mixed>
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $uidvalid : mixed
-
The IMAP uidvalidity value of the mailbox.
- $entries : mixed
-
An array of entries to return. If empty, returns all metadata.
Return values
array<string|int, mixed> —The requested metadata. Requested entries that do not exist will be undefined. The following entries are defaults and always present:
- uidvalid: (integer) The UIDVALIDITY of the mailbox.
serialize()
public
serialize() : mixed
Return values
mixed —set()
Store data in cache.
public
set(mixed $mailbox, mixed $data, mixed $uidvalid) : mixed
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $data : mixed
-
The list of data to save. The keys are the UIDs, the values are an array of information to save.
- $uidvalid : mixed
-
The IMAP uidvalidity value of the mailbox.
Return values
mixed —setMetaData()
Set metadata information for a mailbox.
public
setMetaData(mixed $mailbox, mixed $data) : mixed
Parameters
- $mailbox : mixed
-
An IMAP mailbox string.
- $data : mixed
-
The list of data to save. The keys are the metadata IDs, the values are the associated data. (If present, uidvalidity appears as the 'uidvalid' key in $data.)
Return values
mixed —setParams()
Add configuration parameters.
public
setParams([array<string|int, mixed> $params = array() ]) : mixed
Parameters
- $params : array<string|int, mixed> = array()
-
Configuration parameters.
Return values
mixed —unserialize()
public
unserialize(mixed $data) : mixed
Parameters
- $data : mixed
Return values
mixed —_createUid()
Create and return the UID for a mailbox/user/server combo.
protected
_createUid(string $mailbox) : string
Parameters
- $mailbox : string
-
Mailbox name.
Return values
string —UID from base table.
_getUid()
Return the UID for a mailbox/user/server combo.
protected
_getUid(string $mailbox) : string
Parameters
- $mailbox : string
-
Mailbox name.
Return values
string —UID from base table.
_initOb()
Initialization tasks.
protected
_initOb() : mixed
Return values
mixed —_value()
Convert data from/to storage format.
protected
_value(mixed|MongoBinData $data) : mixed|MongoBinData
Parameters
- $data : mixed|MongoBinData
-
The data object.
Return values
mixed|MongoBinData —The converted data.