FileAccess Orion

Memory extends AbstractAdapter
in package
implements AvailableSpaceCapableInterface, ClearByPrefixInterface, ClearByNamespaceInterface, ClearExpiredInterface, FlushableInterface, IterableInterface, TaggableInterface, TotalSpaceCapableInterface

Interfaces, Classes, Traits and Enums

AvailableSpaceCapableInterface
ClearByPrefixInterface
ClearByNamespaceInterface
ClearExpiredInterface
FlushableInterface
IterableInterface
TaggableInterface
TotalSpaceCapableInterface

Table of Contents

$capabilities  : null|Capabilities
Capabilities of this adapter
$capabilityMarker  : null|object
Marker to change capabilities
$data  : array<string|int, mixed>
Data Array
$eventHandles  : array<string|int, mixed>
Event handles of this adapter
$events  : null|EventManagerInterface
The used EventManager if any
$options  : mixed
options
$pluginRegistry  : SplObjectStorage
The plugin registry
__construct()  : mixed
Constructor
__destruct()  : void
Destructor
addItem()  : bool
Add an item.
addItems()  : array<string|int, mixed>
Add multiple items.
addPlugin()  : AbstractAdapter
Register a plugin
checkAndSetItem()  : bool
Set an item only if token matches
clearByNamespace()  : bool
Remove items of given namespace
clearByPrefix()  : bool
Remove items matching given prefix
clearByTags()  : bool
Remove items matching given tags.
clearExpired()  : bool
Remove expired items
decrementItem()  : int|bool
Decrement an item.
decrementItems()  : array<string|int, mixed>
Decrement multiple items.
flush()  : bool
Flush the whole storage
getAvailableSpace()  : int|float
Get available space in bytes
getCaching()  : bool
Get caching enabled.
getCapabilities()  : Capabilities
Get capabilities of this adapter
getEventManager()  : EventManagerInterface
Get the event manager
getItem()  : mixed
Get an item.
getItems()  : array<string|int, mixed>
Get multiple items.
getIterator()  : KeyListIterator
Get the storage iterator
getMetadata()  : array<string|int, mixed>|bool
Get metadata of an item.
getMetadatas()  : array<string|int, mixed>
Get multiple metadata
getOptions()  : MemoryOptions
Get options.
getPluginRegistry()  : SplObjectStorage
Return registry of plugins
getTags()  : array<string|int, string>|false
Get tags of an item by given key
getTotalSpace()  : int
Get total space in bytes
hasItem()  : bool
Test if an item exists.
hasItems()  : array<string|int, mixed>
Test multiple items.
hasPlugin()  : bool
Check if a plugin is registered
incrementItem()  : int|bool
Increment an item.
incrementItems()  : array<string|int, mixed>
Increment multiple items.
removeItem()  : bool
Remove an item.
removeItems()  : array<string|int, mixed>
Remove multiple items.
removePlugin()  : AbstractAdapter
Unregister an already registered plugin
replaceItem()  : bool
Replace an existing item.
replaceItems()  : array<string|int, mixed>
Replace multiple existing items.
setCaching()  : AbstractAdapter
Enable/Disable caching.
setItem()  : bool
Store an item.
setItems()  : array<string|int, mixed>
Store multiple items.
setOptions()  : Memory
Set options.
setTags()  : bool
Set tags to an item by given key.
touchItem()  : bool
Reset lifetime of an item
touchItems()  : array<string|int, mixed>
Reset lifetime of multiple items.
hasAvailableSpace()  : bool
Has space available to store items?
internalAddItem()  : bool
Add an item.
internalAddItems()  : array<string|int, mixed>
Internal method to add multiple items.
internalCheckAndSetItem()  : bool
Internal method to set an item only if token matches
internalDecrementItem()  : int|bool
Internal method to decrement an item.
internalDecrementItems()  : array<string|int, mixed>
Internal method to decrement multiple items.
internalGetCapabilities()  : Capabilities
Internal method to get capabilities of this adapter
internalGetItem()  : mixed
Internal method to get an item.
internalGetItems()  : array<string|int, mixed>
Internal method to get multiple items.
internalGetMetadata()  : array<string|int, mixed>|bool
Get metadata of an item.
internalGetMetadatas()  : array<string|int, mixed>
Internal method to get multiple metadata
internalHasItem()  : bool
Internal method to test if an item exists.
internalHasItems()  : array<string|int, mixed>
Internal method to test multiple items.
internalIncrementItem()  : int|bool
Internal method to increment an item.
internalIncrementItems()  : array<string|int, mixed>
Internal method to increment multiple items.
internalRemoveItem()  : bool
Internal method to remove an item.
internalRemoveItems()  : array<string|int, mixed>
Internal method to remove multiple items.
internalReplaceItem()  : bool
Internal method to replace an existing item.
internalReplaceItems()  : array<string|int, mixed>
Internal method to replace multiple existing items.
internalSetItem()  : bool
Internal method to store an item.
internalSetItems()  : array<string|int, mixed>
Internal method to store multiple items.
internalTouchItem()  : bool
Internal method to reset lifetime of an item
internalTouchItems()  : array<string|int, mixed>
Internal method to reset lifetime of multiple items.
normalizeKey()  : void
Validates and normalizes a key
normalizeKeys()  : void
Validates and normalizes multiple keys
normalizeKeyValuePairs()  : void
Validates and normalizes an array of key-value pairs
triggerException()  : mixed
Trigger an exception event
triggerPost()  : mixed
Triggers the PostEvent and return the result value.
triggerPre()  : ResponseCollection
Trigger a pre event and return the event response collection

Properties

$capabilityMarker

Marker to change capabilities

protected null|object $capabilityMarker

$data

Data Array

protected array<string|int, mixed> $data = []

Format: array( <NAMESPACE> => array( <KEY> => array( 0 => <VALUE> 1 => <MICROTIME> ['tags' => <TAGS>] ) ) )

$eventHandles

Event handles of this adapter

protected array<string|int, mixed> $eventHandles = []

$pluginRegistry

The plugin registry

protected SplObjectStorage $pluginRegistry

Registered plugins

Methods

__destruct()

Destructor

public __destruct() : void

detach all registered plugins to free event handles of event manager

Return values
void

addItem()

Add an item.

public addItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

addItem.pre(PreEvent)

triggers

addItem.post(PostEvent)

triggers

addItem.exception(ExceptionEvent)

Return values
bool

addItems()

Add multiple items.

public addItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

addItems.pre(PreEvent)

triggers

addItems.post(PostEvent)

triggers

addItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

checkAndSetItem()

Set an item only if token matches

public checkAndSetItem(mixed $token, string $key, mixed $value) : bool

It uses the token received from getItem() to check if the item has changed before overwriting it.

Parameters
$token : mixed
$key : string
$value : mixed
Tags
throws
ExceptionInterface
see
getItem()
see
setItem()
Return values
bool

clearByNamespace()

Remove items of given namespace

public clearByNamespace(mixed $namespace) : bool
Parameters
$namespace : mixed
Return values
bool

clearByPrefix()

Remove items matching given prefix

public clearByPrefix(string $prefix) : bool
Parameters
$prefix : string
Return values
bool

clearByTags()

Remove items matching given tags.

public clearByTags(array<string|int, string> $tags[, bool $disjunction = false ]) : bool

If $disjunction only one of the given tags must match else all given tags must match.

Parameters
$tags : array<string|int, string>
$disjunction : bool = false
Return values
bool

clearExpired()

Remove expired items

public clearExpired() : bool
Return values
bool

decrementItem()

Decrement an item.

public decrementItem(string $key, int $value) : int|bool
Parameters
$key : string
$value : int
Tags
throws
ExceptionInterface
triggers

decrementItem.pre(PreEvent)

triggers

decrementItem.post(PostEvent)

triggers

decrementItem.exception(ExceptionEvent)

Return values
int|bool

The new value on success, false on failure

decrementItems()

Decrement multiple items.

public decrementItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

incrementItems.pre(PreEvent)

triggers

incrementItems.post(PostEvent)

triggers

incrementItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and new values

flush()

Flush the whole storage

public flush() : bool
Return values
bool

getAvailableSpace()

Get available space in bytes

public getAvailableSpace() : int|float
Return values
int|float

getCaching()

Get caching enabled.

public getCaching() : bool

Alias of getWritable and getReadable.

Tags
see
getWritable()
see
getReadable()
Return values
bool

getCapabilities()

Get capabilities of this adapter

public getCapabilities() : Capabilities
Tags
triggers

getCapabilities.pre(PreEvent)

triggers

getCapabilities.post(PostEvent)

triggers

getCapabilities.exception(ExceptionEvent)

Return values
Capabilities

getItem()

Get an item.

public getItem(string $key[, bool &$success = null ][, mixed &$casToken = null ]) : mixed
Parameters
$key : string
$success : bool = null
$casToken : mixed = null
Tags
throws
ExceptionInterface
triggers

getItem.pre(PreEvent)

triggers

getItem.post(PostEvent)

triggers

getItem.exception(ExceptionEvent)

Return values
mixed

Data on success, null on failure

getItems()

Get multiple items.

public getItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

getItems.pre(PreEvent)

triggers

getItems.post(PostEvent)

triggers

getItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and values

getMetadata()

Get metadata of an item.

public getMetadata(string $key) : array<string|int, mixed>|bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

getMetadata.pre(PreEvent)

triggers

getMetadata.post(PostEvent)

triggers

getMetadata.exception(ExceptionEvent)

Return values
array<string|int, mixed>|bool

Metadata on success, false on failure

getMetadatas()

Get multiple metadata

public getMetadatas(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

getMetadatas.pre(PreEvent)

triggers

getMetadatas.post(PostEvent)

triggers

getMetadatas.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and metadata

getPluginRegistry()

Return registry of plugins

public getPluginRegistry() : SplObjectStorage
Return values
SplObjectStorage

getTags()

Get tags of an item by given key

public getTags(string $key) : array<string|int, string>|false
Parameters
$key : string
Return values
array<string|int, string>|false

getTotalSpace()

Get total space in bytes

public getTotalSpace() : int
Return values
int

hasItem()

Test if an item exists.

public hasItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

hasItem.pre(PreEvent)

triggers

hasItem.post(PostEvent)

triggers

hasItem.exception(ExceptionEvent)

Return values
bool

hasItems()

Test multiple items.

public hasItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

hasItems.pre(PreEvent)

triggers

hasItems.post(PostEvent)

triggers

hasItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of found keys

incrementItem()

Increment an item.

public incrementItem(string $key, int $value) : int|bool
Parameters
$key : string
$value : int
Tags
throws
ExceptionInterface
triggers

incrementItem.pre(PreEvent)

triggers

incrementItem.post(PostEvent)

triggers

incrementItem.exception(ExceptionEvent)

Return values
int|bool

The new value on success, false on failure

incrementItems()

Increment multiple items.

public incrementItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

incrementItems.pre(PreEvent)

triggers

incrementItems.post(PostEvent)

triggers

incrementItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Associative array of keys and new values

removeItem()

Remove an item.

public removeItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

removeItem.pre(PreEvent)

triggers

removeItem.post(PostEvent)

triggers

removeItem.exception(ExceptionEvent)

Return values
bool

removeItems()

Remove multiple items.

public removeItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

removeItems.pre(PreEvent)

triggers

removeItems.post(PostEvent)

triggers

removeItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not removed keys

replaceItem()

Replace an existing item.

public replaceItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

replaceItem.pre(PreEvent)

triggers

replaceItem.post(PostEvent)

triggers

replaceItem.exception(ExceptionEvent)

Return values
bool

replaceItems()

Replace multiple existing items.

public replaceItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

replaceItems.pre(PreEvent)

triggers

replaceItems.post(PostEvent)

triggers

replaceItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

setCaching()

Enable/Disable caching.

public setCaching(bool $flag) : AbstractAdapter

Alias of setWritable and setReadable.

Parameters
$flag : bool
Tags
see
setWritable()
see
setReadable()
Return values
AbstractAdapter

Provides a fluent interface

setItem()

Store an item.

public setItem(string $key, mixed $value) : bool
Parameters
$key : string
$value : mixed
Tags
throws
ExceptionInterface
triggers

setItem.pre(PreEvent)

triggers

setItem.post(PostEvent)

triggers

setItem.exception(ExceptionEvent)

Return values
bool

setItems()

Store multiple items.

public setItems(array<string|int, mixed> $keyValuePairs) : array<string|int, mixed>
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

setItems.pre(PreEvent)

triggers

setItems.post(PostEvent)

triggers

setItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not stored keys

setOptions()

Set options.

public setOptions(array<string|int, mixed>|Traversable|MemoryOptions $options) : Memory
Parameters
$options : array<string|int, mixed>|Traversable|MemoryOptions
Tags
see
getOptions()
Return values
Memory

setTags()

Set tags to an item by given key.

public setTags(string $key, array<string|int, string> $tags) : bool

An empty array will remove all tags.

Parameters
$key : string
$tags : array<string|int, string>
Return values
bool

touchItem()

Reset lifetime of an item

public touchItem(string $key) : bool
Parameters
$key : string
Tags
throws
ExceptionInterface
triggers

touchItem.pre(PreEvent)

triggers

touchItem.post(PostEvent)

triggers

touchItem.exception(ExceptionEvent)

Return values
bool

touchItems()

Reset lifetime of multiple items.

public touchItems(array<string|int, mixed> $keys) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>
Tags
throws
ExceptionInterface
triggers

touchItems.pre(PreEvent)

triggers

touchItems.post(PostEvent)

triggers

touchItems.exception(ExceptionEvent)

Return values
array<string|int, mixed>

Array of not updated keys

hasAvailableSpace()

Has space available to store items?

protected hasAvailableSpace() : bool
Return values
bool

internalAddItem()

Add an item.

protected internalAddItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalAddItems()

Internal method to add multiple items.

protected internalAddItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalCheckAndSetItem()

Internal method to set an item only if token matches

protected internalCheckAndSetItem(mixed &$token, string &$normalizedKey, mixed &$value) : bool
Parameters
$token : mixed
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
see
getItem()
see
setItem()
Return values
bool

internalDecrementItem()

Internal method to decrement an item.

protected internalDecrementItem(string &$normalizedKey, int &$value) : int|bool
Parameters
$normalizedKey : string
$value : int
Tags
throws
ExceptionInterface
Return values
int|bool

The new value on success, false on failure

internalDecrementItems()

Internal method to decrement multiple items.

protected internalDecrementItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and new values

internalGetCapabilities()

Internal method to get capabilities of this adapter

protected internalGetCapabilities() : Capabilities
Return values
Capabilities

internalGetItem()

Internal method to get an item.

protected internalGetItem(string &$normalizedKey[, bool &$success = null ][, mixed &$casToken = null ]) : mixed
Parameters
$normalizedKey : string
$success : bool = null
$casToken : mixed = null
Tags
throws
ExceptionInterface
Return values
mixed

Data on success, null on failure

internalGetItems()

Internal method to get multiple items.

protected internalGetItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and values

internalGetMetadata()

Get metadata of an item.

protected internalGetMetadata(string &$normalizedKey) : array<string|int, mixed>|bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
triggers

getMetadata.pre(PreEvent)

triggers

getMetadata.post(PostEvent)

triggers

getMetadata.exception(ExceptionEvent)

Return values
array<string|int, mixed>|bool

Metadata on success, false on failure

internalGetMetadatas()

Internal method to get multiple metadata

protected internalGetMetadatas(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and metadata

internalHasItem()

Internal method to test if an item exists.

protected internalHasItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Return values
bool

internalHasItems()

Internal method to test multiple items.

protected internalHasItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Return values
array<string|int, mixed>

Array of found keys

internalIncrementItem()

Internal method to increment an item.

protected internalIncrementItem(string &$normalizedKey, int &$value) : int|bool
Parameters
$normalizedKey : string
$value : int
Tags
throws
ExceptionInterface
Return values
int|bool

The new value on success, false on failure

internalIncrementItems()

Internal method to increment multiple items.

protected internalIncrementItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Associative array of keys and new values

internalRemoveItem()

Internal method to remove an item.

protected internalRemoveItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
bool

internalRemoveItems()

Internal method to remove multiple items.

protected internalRemoveItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not removed keys

internalReplaceItem()

Internal method to replace an existing item.

protected internalReplaceItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalReplaceItems()

Internal method to replace multiple existing items.

protected internalReplaceItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalSetItem()

Internal method to store an item.

protected internalSetItem(string &$normalizedKey, mixed &$value) : bool
Parameters
$normalizedKey : string
$value : mixed
Tags
throws
ExceptionInterface
Return values
bool

internalSetItems()

Internal method to store multiple items.

protected internalSetItems(array<string|int, mixed> &$normalizedKeyValuePairs) : array<string|int, mixed>
Parameters
$normalizedKeyValuePairs : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not stored keys

internalTouchItem()

Internal method to reset lifetime of an item

protected internalTouchItem(string &$normalizedKey) : bool
Parameters
$normalizedKey : string
Tags
throws
ExceptionInterface
Return values
bool

internalTouchItems()

Internal method to reset lifetime of multiple items.

protected internalTouchItems(array<string|int, mixed> &$normalizedKeys) : array<string|int, mixed>
Parameters
$normalizedKeys : array<string|int, mixed>
Tags
throws
ExceptionInterface
Return values
array<string|int, mixed>

Array of not updated keys

normalizeKey()

Validates and normalizes a key

protected normalizeKey(string &$key) : void
Parameters
$key : string
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

normalizeKeys()

Validates and normalizes multiple keys

protected normalizeKeys(array<string|int, mixed> &$keys) : void
Parameters
$keys : array<string|int, mixed>
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

normalizeKeyValuePairs()

Validates and normalizes an array of key-value pairs

protected normalizeKeyValuePairs(array<string|int, mixed> &$keyValuePairs) : void
Parameters
$keyValuePairs : array<string|int, mixed>
Tags
throws
InvalidArgumentException

On an invalid key

Return values
void

triggerException()

Trigger an exception event

protected triggerException(string $eventName, ArrayObject $args, mixed &$result, Exception $exception) : mixed

If the ExceptionEvent has the flag "throwException" enabled throw the exception after trigger else return the result.

Parameters
$eventName : string
$args : ArrayObject
$result : mixed
$exception : Exception
Tags
throws
ExceptionInterface
Return values
mixed

triggerPost()

Triggers the PostEvent and return the result value.

protected triggerPost(string $eventName, ArrayObject $args, mixed &$result) : mixed
Parameters
$eventName : string
$args : ArrayObject
$result : mixed
Return values
mixed

triggerPre()

Trigger a pre event and return the event response collection

protected triggerPre(string $eventName, ArrayObject $args) : ResponseCollection
Parameters
$eventName : string
$args : ArrayObject
Return values
ResponseCollection

All handler return values

Search results