Elgg  Version 1.11
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Cache\MetadataCache Class Reference

In memory cache of known metadata values stored by entity. More...

Public Member Functions

 __construct (\ElggSession $session)
 Constructor. More...
 
 inject ($entity_guid, array $values)
 Set the visible metadata for an entity in the cache. More...
 
 getSingle ($entity_guid, $name)
 Get the metadata for a particular name. More...
 
 clear ($entity_guid)
 Forget about all metadata for an entity. More...
 
 isLoaded ($entity_guid)
 If true, getSingle() will return an accurate values from the DB. More...
 
 clearAll ()
 Clear entire cache. More...
 
 invalidateByOptions (array $options)
 Invalidate based on options passed to the global *_metadata functions. More...
 
 populateFromEntities ($guids)
 Populate the cache from a set of entities. More...
 
 filterMetadataHeavyEntities (array $guids, $limit=1024000)
 Filter out entities whose concatenated metadata values (INTs casted as string) exceed a threshold in characters. More...
 

Protected Member Functions

 getAccessKey ()
 Get a key to represent the access ability of the system. More...
 

Protected Attributes

 $values = array()
 
 $session
 

Detailed Description

In memory cache of known metadata values stored by entity.

private

Definition at line 9 of file MetadataCache.php.

Constructor & Destructor Documentation

Elgg\Cache\MetadataCache::__construct ( \ElggSession  $session)

Constructor.

Parameters
\ElggSession$sessionThe session service

Definition at line 28 of file MetadataCache.php.

Member Function Documentation

Elgg\Cache\MetadataCache::clear (   $entity_guid)

Forget about all metadata for an entity.

For safety this affects all access states.

Parameters
int$entity_guidThe GUID of the entity
Returns
void

Definition at line 77 of file MetadataCache.php.

Elgg\Cache\MetadataCache::clearAll ( )

Clear entire cache.

Returns
void

Definition at line 103 of file MetadataCache.php.

Elgg\Cache\MetadataCache::filterMetadataHeavyEntities ( array  $guids,
  $limit = 1024000 
)

Filter out entities whose concatenated metadata values (INTs casted as string) exceed a threshold in characters.

This could be used to avoid overpopulating the cache if RAM usage becomes an issue.

Parameters
array$guidsGUIDs of entities to examine
int$limitLimit in characters of all metadata (with ints casted to strings)
Returns
array

Definition at line 202 of file MetadataCache.php.

Elgg\Cache\MetadataCache::getAccessKey ( )
protected

Get a key to represent the access ability of the system.

This is used to shard the cache array.

Returns
string E.g. "ignored" or "123"

Definition at line 229 of file MetadataCache.php.

Elgg\Cache\MetadataCache::getSingle (   $entity_guid,
  $name 
)

Get the metadata for a particular name.

Note, this can return an array of values.

Warning: You should always call isLoaded() beforehand to verify that this function's return value can be trusted.

See also
isLoaded
Parameters
int$entity_guidThe GUID of the entity
string$nameThe metadata name
Returns
array|string|int|null null = value does not exist

Definition at line 60 of file MetadataCache.php.

Elgg\Cache\MetadataCache::inject (   $entity_guid,
array  $values 
)

Set the visible metadata for an entity in the cache.

Note this does NOT invalidate any other part of the cache.

Parameters
int$entity_guidThe GUID of the entity
array$valuesThe metadata values to cache
Returns
void

private For testing only

Definition at line 43 of file MetadataCache.php.

Elgg\Cache\MetadataCache::invalidateByOptions ( array  $options)

Invalidate based on options passed to the global *_metadata functions.

Parameters
array$optionsOptions passed to elgg_(delete|disable|enable)_metadata "guid" if given, invalidation will be limited to this entity
Returns
void

Definition at line 114 of file MetadataCache.php.

Elgg\Cache\MetadataCache::isLoaded (   $entity_guid)

If true, getSingle() will return an accurate values from the DB.

Parameters
int$entity_guidThe GUID of the entity
Returns
bool

Definition at line 89 of file MetadataCache.php.

Elgg\Cache\MetadataCache::populateFromEntities (   $guids)

Populate the cache from a set of entities.

Parameters
int | array$guidsArray of or single GUIDs
Returns
void

Definition at line 128 of file MetadataCache.php.

Member Data Documentation

Elgg\Cache\MetadataCache::$session
protected

Definition at line 21 of file MetadataCache.php.

Elgg\Cache\MetadataCache::$values = array()
protected

Definition at line 16 of file MetadataCache.php.


The documentation for this class was generated from the following file: