20 private $entities = [];
25 private $disabled_guids = [];
35 private $metadata_cache;
40 private $username_cache = [];
49 $this->session = $session;
50 $this->metadata_cache = $metadata_cache;
52 $GLOBALS[
'ENTITY_CACHE'] = $this->entities;
67 if (isset($this->entities[
$guid]) && $this->entities[
$guid]->isFullyLoaded()) {
68 return $this->entities[
$guid];
81 if (isset($this->username_cache[
$username])) {
82 return $this->
get($this->username_cache[
$username]);
98 if (!
$guid || isset($this->entities[
$guid]) || isset($this->disabled_guids[$guid])) {
110 if (count($this->entities) > self::MAX_SIZE) {
111 $this->
remove(array_rand($this->entities));
115 $GLOBALS[
'ENTITY_CACHE'] = $this->entities;
129 $this->checkGlobal();
133 if (!isset($this->entities[
$guid])) {
137 unset($this->entities[$guid]);
138 $GLOBALS[
'ENTITY_CACHE'] = $this->entities;
140 $username = array_search($guid, $this->username_cache);
149 $this->metadata_cache->clear($guid);
158 $this->checkGlobal();
159 $this->entities = [];
160 $this->username_cache = [];
161 $GLOBALS[
'ENTITY_CACHE'] = $this->entities;
173 $this->
remove(
$guid);
174 $this->disabled_guids[
$guid] =
true;
184 unset($this->disabled_guids[
$guid]);
193 private function checkGlobal() {
194 if (!isset($GLOBALS[
'ENTITY_CACHE']) || ($GLOBALS[
'ENTITY_CACHE'] !== $this->entities)) {
195 $GLOBALS[
'ENTITY_CACHE'] = $this->entities;
$guid
Removes an admin notice.
disableCachingForEntity($guid)
Remove this entity from the entity cache and make sure it is not re-added.
Volatile cache for entities.
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
getByUsername($username)
Returns cached user entity by username.
__construct(ElggSession $session, MetadataCache $metadata_cache)
Constructor.
clear()
Clear the entity cache.
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
enableCachingForEntity($guid)
Allow this entity to be stored in the entity cache.