Elgg  Version 5.1
Public 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 (BaseCache $cache)
 Constructor. More...
 
 inject ($entity_guid, array $values=[])
 Set the visible metadata for an entity in the cache. More...
 
 getAll ($entity_guid)
 Get all entity metadata. More...
 
 getSingle ($entity_guid, $name)
 Get the metadata for a particular name. More...
 
 getSingleId ($entity_guid, $name)
 Get the metadata id 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...
 
 getEntityMetadata ($entity_guid)
 Returns loaded entity metadata. 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 Attributes

 $cache
 

Detailed Description

In memory cache of known metadata values stored by entity.

Definition at line 15 of file MetadataCache.php.

Constructor & Destructor Documentation

Elgg\Cache\MetadataCache::__construct ( BaseCache  $cache)

Constructor.

Parameters
BaseCache$cacheCache

Definition at line 27 of file MetadataCache.php.

Member Function Documentation

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

Forget about all metadata for an entity.

Parameters
int$entity_guidThe GUID of the entity
Returns
void

Definition at line 163 of file MetadataCache.php.

Elgg\Cache\MetadataCache::clearAll ( )

Clear entire cache.

Returns
void

Definition at line 185 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 281 of file MetadataCache.php.

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

Get all entity metadata.

Parameters
int$entity_guidEntity guid
Returns
array

Definition at line 67 of file MetadataCache.php.

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

Returns loaded entity metadata.

Parameters
int$entity_guidEntity guid
Returns
[]|null

Definition at line 196 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
MetadataCache::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 97 of file MetadataCache.php.

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

Get the metadata id for a particular name.

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

See also
MetadataCache::isLoaded()
Parameters
int$entity_guidThe GUID of the entity
string$nameThe metadata name
Returns
int[]|int|null

Definition at line 133 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

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 213 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 176 of file MetadataCache.php.

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

Populate the cache from a set of entities.

Parameters
int[]...$guids Array of or single GUIDs
Returns
array|null [guid => [metadata]]

Definition at line 228 of file MetadataCache.php.

Member Data Documentation

Elgg\Cache\MetadataCache::$cache
protected

Definition at line 20 of file MetadataCache.php.


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