Registry Service¶
Simple Memory cache class, handy for use before TYPO3 native caches are available (they can not be injected/instantiated during ext_localconf.php).
- class Jar\Utilities\Services\RegistryService¶
- set($storeName, $key, $value)¶
Put a item in a store.
- Parameters
$storeName (
string
) -- Name of the store.$key (
string
) -- Key of the item.$value (
mixed
) -- Value of the item.
- Returns
self
- get($storeName, $key)¶
Returns a value out of a store.
- Parameters
$storeName (
string
) -- Name of the store.$key (
string
) -- Key of the item.
- Returns
Value of the item or
false
.
- getWholeStore($storeName)¶
Returns the whole content of a store.
- Parameters
$storeName (
string
) -- Name of the store.
- Returns
Value of the store or
null
.
Example:
$cache = GeneralUtility::makeInstance(RegistryService::class);
$hash = 'my-elements';
if (($elements = $cache->get('my-little-store', $hash)) === false) {
$elements = [1, 2, 3, 4, 5];
$cache->set('my-little-store', $hash, $elements);
}
var_dump($cache->getWholeStore('my-little-store'));
// Result of var_dump:
[
'my-elements' => [1, 2, 3, 4, 5]
]