PHP Class Mongolid\Cursor\CacheableCursor

Inheritance: extends Cursor
Show file Open project: leroy-merlin-br/mongolid

Protected Properties

Property Type Description
$documents array The documents that were retrieved from the database in a serializable way.
$ignoreCache boolean Means that the CacheableCursor is wapping the original cursor and not reading from Cache anymore.
$originalLimit ìnteger Limit of the query. It is stored because when caching the documents the DOCUMENT_LIMIT const will be used.

Public Methods

Method Description
serialize ( ) : string Serializes this object. Drops the unserializable DriverCursor. In order to make the CacheableCursor object serializable.

Protected Methods

Method Description
generateCacheKey ( ) : string Generates an unique cache key for the cursor in it's current state.
getCursor ( ) : Traversable Actually returns a Traversable object with the DriverCursor within.
getLimit ( ) : mixed Gets the limit clause of the query if any.
getOriginalCursor ( ) : Traversable Returns the DriverCursor considering the documents that have already been retrieved from cache.
storeOriginalLimit ( ) : void Stores the original "limit" clause of the query.

Method Details

generateCacheKey() protected method

Generates an unique cache key for the cursor in it's current state.
protected generateCacheKey ( ) : string
return string Cache key to identify the query of the current cursor.

getCursor() protected method

If it does not exists yet, create it using the $collection, $command and $params given. The difference between the CacheableCursor and the normal Cursor is that the Cacheable stores all the results within itself and drops the Driver Cursor in order to be serializable.
protected getCursor ( ) : Traversable
return Traversable

getLimit() protected method

Gets the limit clause of the query if any.
protected getLimit ( ) : mixed
return mixed Int or null

getOriginalCursor() protected method

Returns the DriverCursor considering the documents that have already been retrieved from cache.
protected getOriginalCursor ( ) : Traversable
return Traversable

serialize() public method

Serializes this object. Drops the unserializable DriverCursor. In order to make the CacheableCursor object serializable.
public serialize ( ) : string
return string Serialized object.

storeOriginalLimit() protected method

Stores the original "limit" clause of the query.
protected storeOriginalLimit ( ) : void
return void

Property Details

$documents protected property

The documents that were retrieved from the database in a serializable way.
protected array $documents
return array

$ignoreCache protected property

Means that the CacheableCursor is wapping the original cursor and not reading from Cache anymore.
protected bool $ignoreCache
return boolean

$originalLimit protected property

Limit of the query. It is stored because when caching the documents the DOCUMENT_LIMIT const will be used.
protected ìnteger $originalLimit
return ìnteger