SysVCacheItemPool
in package
implements
CacheItemPoolInterface
SystemV shared memory based CacheItemPool implementation.
This CacheItemPool implementation can be used among multiple processes, but it doesn't provide any locking mechanism. If multiple processes write to this ItemPool, you have to avoid race condition manually in your code.
Table of Contents
Interfaces
- CacheItemPoolInterface
- CacheItemPoolInterface generates CacheItemInterface objects.
Constants
- DEFAULT_MEMSIZE = 10000
- DEFAULT_PERM = 0600
- DEFAULT_PROJ = 'A'
- VAR_KEY = 1
Properties
- $deferredItems : array<string|int, CacheItemInterface>
- $hasLoadedItems : mixed
- $items : array<string|int, CacheItemInterface>
- $options : array<string|int, mixed>
- $sysvKey : int
Methods
- __construct() : mixed
- Create a SystemV shared memory based CacheItemPool.
- clear() : bool
- Deletes all items in the pool.
- commit() : bool
- Persists any deferred cache items.
- deleteItem() : bool
- Removes the item from the pool.
- deleteItems() : bool
- Removes multiple items from the pool.
- getItem() : CacheItemInterface
- Returns a Cache Item representing the specified key.
- getItems() : array<string|int, mixed>|Traversable
- Returns a traversable set of cache items.
- hasItem() : bool
- Confirms if the cache contains specified cache item.
- save() : bool
- Persists a cache item immediately.
- saveDeferred() : bool
- Sets a cache item to be persisted later.
- loadItems() : bool
- Load the items from the shared memory.
- saveCurrentItems() : bool
- Save the current items.
Constants
DEFAULT_MEMSIZE
public
mixed
DEFAULT_MEMSIZE
= 10000
DEFAULT_PERM
public
mixed
DEFAULT_PERM
= 0600
DEFAULT_PROJ
public
mixed
DEFAULT_PROJ
= 'A'
VAR_KEY
public
mixed
VAR_KEY
= 1
Properties
$deferredItems
private
array<string|int, CacheItemInterface>
$deferredItems
$hasLoadedItems
private
mixed
$hasLoadedItems
= false
$items
private
array<string|int, CacheItemInterface>
$items
$options
private
array<string|int, mixed>
$options
$sysvKey
private
int
$sysvKey
Methods
__construct()
Create a SystemV shared memory based CacheItemPool.
public
__construct([mixed $options = [] ]) : mixed
Parameters
- $options : mixed = []
-
.perm int The permission for shm_attach. Defaults to 0600.
clear()
Deletes all items in the pool.
public
clear() : bool
Return values
bool —True if the pool was successfully cleared. False if there was an error.
commit()
Persists any deferred cache items.
public
commit() : bool
Return values
bool —True if all not-yet-saved items were successfully saved or there were none. False otherwise.
deleteItem()
Removes the item from the pool.
public
deleteItem(mixed $key) : bool
Parameters
- $key : mixed
-
The key to delete.
Return values
bool —True if the item was successfully removed. False if there was an error.
deleteItems()
Removes multiple items from the pool.
public
deleteItems(array<string|int, mixed> $keys) : bool
Parameters
- $keys : array<string|int, mixed>
-
An array of keys that should be removed from the pool.
Return values
bool —True if the items were successfully removed. False if there was an error.
getItem()
Returns a Cache Item representing the specified key.
public
getItem(mixed $key) : CacheItemInterface
This method must always return a CacheItemInterface object, even in case of a cache miss. It MUST NOT return null.
Parameters
- $key : mixed
-
The key for which to return the corresponding Cache Item.
Return values
CacheItemInterface —The corresponding Cache Item.
getItems()
Returns a traversable set of cache items.
public
getItems([array<string|int, mixed> $keys = [] ]) : array<string|int, mixed>|Traversable
Parameters
- $keys : array<string|int, mixed> = []
-
An indexed array of keys of items to retrieve.
Return values
array<string|int, mixed>|Traversable —A traversable collection of Cache Items keyed by the cache keys of each item. A Cache item will be returned for each key, even if that key is not found. However, if no keys are specified then an empty traversable MUST be returned instead.
hasItem()
Confirms if the cache contains specified cache item.
public
hasItem(mixed $key) : bool
Parameters
- $key : mixed
-
The key for which to check existence.
Return values
bool —True if item exists in the cache, false otherwise.
save()
Persists a cache item immediately.
public
save(CacheItemInterface $item) : bool
Parameters
- $item : CacheItemInterface
-
The cache item to save.
Return values
bool —True if the item was successfully persisted. False if there was an error.
saveDeferred()
Sets a cache item to be persisted later.
public
saveDeferred(CacheItemInterface $item) : bool
Parameters
- $item : CacheItemInterface
-
The cache item to save.
Return values
bool —False if the item could not be queued or if a commit was attempted and failed. True otherwise.
loadItems()
Load the items from the shared memory.
private
loadItems() : bool
Return values
bool —true when success, false upon failure
saveCurrentItems()
Save the current items.
private
saveCurrentItems() : bool
Return values
bool —true when success, false upon failure