\Horde_Imap_Client_Cache_Backend_Mongo

A MongoDB database implementation for caching IMAP/POP data.

Requires the Horde_Mongo class.

Summary

Methods
Properties
Constants
__construct()
setParams()
get()
getCachedUids()
set()
getMetaData()
setMetaData()
deleteMsgs()
deleteMailbox()
clear()
serialize()
unserialize()
checkMongoIndices()
createMongoIndices()
No public properties found
BASE
MD
MSG
BASE_HOSTSPEC
BASE_MAILBOX
BASE_MODIFIED
BASE_PORT
BASE_UID
BASE_USERNAME
MD_DATA
MD_FIELD
MD_UID
MSG_DATA
MSG_MSGUID
MSG_UID
_initOb()
_getUid()
_createUid()
_value()
$_params
$_db
$_indices
N/A
No private methods found
No private properties found
N/A

Constants

BASE

BASE

Mongo collection names.

MD

MD

MSG

MSG

BASE_HOSTSPEC

BASE_HOSTSPEC

Mongo field names: BASE collection.

BASE_MAILBOX

BASE_MAILBOX

BASE_MODIFIED

BASE_MODIFIED

BASE_PORT

BASE_PORT

BASE_UID

BASE_UID

BASE_USERNAME

BASE_USERNAME

MD_DATA

MD_DATA

Mongo field names: MD collection.

MD_FIELD

MD_FIELD

MD_UID

MD_UID

MSG_DATA

MSG_DATA

Mongo field names: MSG collection.

MSG_MSGUID

MSG_MSGUID

MSG_UID

MSG_UID

Properties

$_params

$_params : array

Configuration paramters.

Values set by the base Cache object: hostspec, port, username

Type

array

$_db

$_db : \MongoDB

The MongoDB object for the cache data.

Type

\MongoDB

$_indices

$_indices : array

The list of indices.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Configuration parameters:

  - REQUIRED parameters:
    - mongo_db: (Horde_Mongo_Client) A MongoDB client object.

setParams()

setParams(array  $params = array()) 

Add configuration parameters.

Parameters

array $params

Configuration parameters.

get()

get(string  $mailbox, array  $uids, array  $fields, integer  $uidvalid) : array

Get information from the cache for a set of UIDs.

Parameters

string $mailbox

An IMAP mailbox string.

array $uids

The list of message UIDs to retrieve information for.

array $fields

An array of fields to retrieve. If empty, returns all cached fields.

integer $uidvalid

The IMAP uidvalidity value of the mailbox.

Returns

array —

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()

getCachedUids(string  $mailbox, integer  $uidvalid) : array

Get the list of cached UIDs.

Parameters

string $mailbox

An IMAP mailbox string.

integer $uidvalid

The IMAP uidvalidity value of the mailbox.

Returns

array —

The (unsorted) list of cached UIDs.

set()

set(string  $mailbox, array  $data, integer  $uidvalid) 

Store data in cache.

Parameters

string $mailbox

An IMAP mailbox string.

array $data

The list of data to save. The keys are the UIDs, the values are an array of information to save.

integer $uidvalid

The IMAP uidvalidity value of the mailbox.

getMetaData()

getMetaData(string  $mailbox, integer  $uidvalid, array  $entries) : array

Get metadata information for a mailbox.

Parameters

string $mailbox

An IMAP mailbox string.

integer $uidvalid

The IMAP uidvalidity value of the mailbox.

array $entries

An array of entries to return. If empty, returns all metadata.

Returns

array —

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.

setMetaData()

setMetaData(string  $mailbox, array  $data) 

Set metadata information for a mailbox.

Parameters

string $mailbox

An IMAP mailbox string.

array $data

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.)

deleteMsgs()

deleteMsgs(string  $mailbox, array  $uids) 

Delete messages in the cache.

Parameters

string $mailbox

An IMAP mailbox string.

array $uids

The list of message UIDs to delete.

deleteMailbox()

deleteMailbox(string  $mailbox) 

Delete a mailbox from the cache.

Parameters

string $mailbox

The mailbox to delete.

clear()

clear(integer  $lifetime) 

Clear the cache.

Parameters

integer $lifetime

Only delete entries older than this (in seconds). If null, deletes all entries.

serialize()

serialize() 

unserialize()

unserialize(  $data) 

Parameters

$data

checkMongoIndices()

checkMongoIndices() 

createMongoIndices()

createMongoIndices() 

_initOb()

_initOb() 

Initialization tasks.

_getUid()

_getUid(string  $mailbox) : string

Return the UID for a mailbox/user/server combo.

Parameters

string $mailbox

Mailbox name.

Returns

string —

UID from base table.

_createUid()

_createUid(string  $mailbox) : string

Create and return the UID for a mailbox/user/server combo.

Parameters

string $mailbox

Mailbox name.

Returns

string —

UID from base table.

_value()

_value(mixed|\MongoBinData  $data) : mixed|\MongoBinData

Convert data from/to storage format.

Parameters

mixed|\MongoBinData $data

The data object.

Returns

mixed|\MongoBinData —

The converted data.