\OntologyWrapper\traitsMemcachedDictionary

Memcached dictionary cache

This trait implements the virtual interface of the {@link DictionaryObject} using the {@link Memcached} class.

This trait requires the constructor, in the class that will be using it, to load the two declared data members and to handle the servers.

Summary

Methods
Properties
Constants
dictionaryFlush()
dictionaryKeys()
No public properties found
No constants found
setEntry()
setEntriesByArray()
setEntriesByIterator()
getEntry()
delEntry()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

dictionaryFlush()

dictionaryFlush(integer $theDelay)

Flush dictionary

In this trait we use the {@link Memcached::flush()} method.

Parameters

integer $theDelay

Delay before flush.

dictionaryKeys()

dictionaryKeys() : array

Return dictionary keys

This trait will return all dictionary keys.

Returns

array —

List of dictionary keys.

setEntry()

setEntry(mixed $theKey, mixed $theValue, integer $theLife)

Set a dictionary entry

In this trait we use the {@link Memcached::set()} method to add entries to the dictionary. This method will receive two kinds of objects:

  • Identifiers: In this case the key is a string representing the persistent identifier of a tag, and the value is an integer representing the native identifier of the tag.
  • Tags: In this case the key is an integer representing the native identifier of the tag and the value is an object or array, representing the tag object.

The method expects the parameters to be correctly casted.

Parameters

mixed $theKey

Entry key.

mixed $theValue

Entry value.

integer $theLife

Entry lifetime.

Throws

\OntologyWrapper\traits\Exception

setEntriesByArray()

setEntriesByArray(array $theEntries, integer $theLife)

Set a list dictionary entries from an array

In this trait we use the {@link Memcached::setMulti()} method to add entries to the dictionary. This method will receive two kinds of objects:

The method expects the parameters to be correctly casted.

Parameters

array $theEntries

Entries array.

integer $theLife

Entry lifetime.

Throws

\OntologyWrapper\traits\Exception

setEntriesByIterator()

setEntriesByIterator(\OntologyWrapper\traits\Iterator $theEntries, integer $theLife)

Set a list of dictionary entries from an iterator

In this trait we use the {@link Memcached::setMulti()} method to add entries to the dictionary. This method expects an iterator indexed by entry key.

The method expects the parameters to be correctly casted.

Parameters

\OntologyWrapper\traits\Iterator $theEntries

Entries iterator.

integer $theLife

Entry lifetime.

Throws

\OntologyWrapper\traits\Exception

getEntry()

getEntry(mixed $theKey) : mixed

Get a dictionary entry

In this trait we use the {@link Memcached::get()} method to retrieve entries from the dictionary. This method will select two kinds of objects:

  • Identifiers: In this case the key is a string representing the persistent identifier of a tag.
  • Tags: In this case the key is an integer representing the native identifier of the tag.

The method expects the parameter to be correctly casted.

Parameters

mixed $theKey

Entry key.

Throws

\OntologyWrapper\traits\Exception

Returns

mixed —

Entry value or NULL.

delEntry()

delEntry(mixed $theKey) : boolean

Get a dictionary entry

In this trait we use the {@link Memcached::delete()} method to delete entries from the dictionary. This method will select two kinds of objects:

  • Identifiers: In this case the key is a string representing the persistent identifier of a tag.
  • Tags: In this case the key is an integer representing the native identifier of the tag.

The method will return TRUE if the entry was deleted, FALSE if the entry was not found and raise an exception on any other error.

The method expects the parameter to be correctly casted.

Parameters

mixed $theKey

Entry key.

Throws

\OntologyWrapper\traits\Exception

Returns

boolean —

TRUE deleted, FALSE not matched.