Dba
extends AbstractAdapter
in package
implements
AvailableSpaceCapableInterface, ClearByNamespaceInterface, ClearByPrefixInterface, FlushableInterface, IterableInterface, OptimizableInterface, TotalSpaceCapableInterface
Interfaces, Classes, Traits and Enums
- AvailableSpaceCapableInterface
- ClearByNamespaceInterface
- ClearByPrefixInterface
- FlushableInterface
- IterableInterface
- OptimizableInterface
- TotalSpaceCapableInterface
Table of Contents
- $capabilities : null|Capabilities
- Capabilities of this adapter
- $capabilityMarker : null|object
- Marker to change capabilities
- $eventHandles : array<string|int, mixed>
- Event handles of this adapter
- $events : null|EventManagerInterface
- The used EventManager if any
- $handle : null|resource
- The DBA resource handle
- $options : mixed
- options
- $pluginRegistry : SplObjectStorage
- The plugin registry
- $totalSpace : null|int|float
- Buffered total space in bytes
- __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 by given namespace
- clearByPrefix() : bool
- Remove items matching given prefix
- decrementItem() : int|bool
- Decrement an item.
- decrementItems() : array<string|int, mixed>
- Decrement multiple items.
- flush() : bool
- Flush the whole storage
- getAvailableSpace() : 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() : DbaIterator
- Get the storage iterator
- getMetadata() : array<string|int, mixed>|bool
- Get metadata of an item.
- getMetadatas() : array<string|int, mixed>
- Get multiple metadata
- getOptions() : DbaOptions
- Get options.
- getPluginRegistry() : SplObjectStorage
- Return registry of plugins
- getTotalSpace() : int|float
- 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.
- optimize() : bool
- Optimize the storage
- 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() : self
- Set options.
- touchItem() : bool
- Reset lifetime of an item
- touchItems() : array<string|int, mixed>
- Reset lifetime of multiple items.
- _close() : void
- Close database file if opened
- _open() : void
- Open the database if not already done.
- 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
- Internal method to 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
$capabilities
Capabilities of this adapter
protected
null|Capabilities
$capabilities
= null
$capabilityMarker
Marker to change capabilities
protected
null|object
$capabilityMarker
$eventHandles
Event handles of this adapter
protected
array<string|int, mixed>
$eventHandles
= []
$events
The used EventManager if any
protected
null|EventManagerInterface
$events
= null
$handle
The DBA resource handle
protected
null|resource
$handle
$options
options
protected
mixed
$options
$pluginRegistry
The plugin registry
protected
SplObjectStorage
$pluginRegistry
Registered plugins
$totalSpace
Buffered total space in bytes
protected
null|int|float
$totalSpace
Methods
__construct()
Constructor
public
__construct([null|array<string|int, mixed>|Traversable|DbaOptions $options = null ]) : mixed
Parameters
- $options : null|array<string|int, mixed>|Traversable|DbaOptions = null
Tags
Return values
mixed —__destruct()
Destructor
public
__destruct() : void
Closes an open dba resource
Tags
Return values
void —addItem()
Add an item.
public
addItem(string $key, mixed $value) : bool
Parameters
- $key : string
- $value : mixed
Tags
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
Return values
array<string|int, mixed> —Array of not stored keys
addPlugin()
Register a plugin
public
addPlugin(PluginInterface $plugin[, int $priority = 1 ]) : AbstractAdapter
Parameters
- $plugin : PluginInterface
- $priority : int = 1
Tags
Return values
AbstractAdapter —Provides a fluent interface
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
Return values
bool —clearByNamespace()
Remove items by given namespace
public
clearByNamespace(string $namespace) : bool
Parameters
- $namespace : string
Return values
bool —clearByPrefix()
Remove items matching given prefix
public
clearByPrefix(string $prefix) : bool
Parameters
- $prefix : string
Return values
bool —decrementItem()
Decrement an item.
public
decrementItem(string $key, int $value) : int|bool
Parameters
- $key : string
- $value : int
Tags
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
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() : float
Return values
float —getCaching()
Get caching enabled.
public
getCaching() : bool
Alias of getWritable and getReadable.
Tags
Return values
bool —getCapabilities()
Get capabilities of this adapter
public
getCapabilities() : Capabilities
Tags
Return values
Capabilities —getEventManager()
Get the event manager
public
getEventManager() : EventManagerInterface
Return values
EventManagerInterface —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
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
Return values
array<string|int, mixed> —Associative array of keys and values
getIterator()
Get the storage iterator
public
getIterator() : DbaIterator
Return values
DbaIterator —getMetadata()
Get metadata of an item.
public
getMetadata(string $key) : array<string|int, mixed>|bool
Parameters
- $key : string
Tags
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
Return values
array<string|int, mixed> —Associative array of keys and metadata
getOptions()
Get options.
public
getOptions() : DbaOptions
Tags
Return values
DbaOptions —getPluginRegistry()
Return registry of plugins
public
getPluginRegistry() : SplObjectStorage
Return values
SplObjectStorage —getTotalSpace()
Get total space in bytes
public
getTotalSpace() : int|float
Return values
int|float —hasItem()
Test if an item exists.
public
hasItem(string $key) : bool
Parameters
- $key : string
Tags
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
Return values
array<string|int, mixed> —Array of found keys
hasPlugin()
Check if a plugin is registered
public
hasPlugin(PluginInterface $plugin) : bool
Parameters
- $plugin : PluginInterface
Return values
bool —incrementItem()
Increment an item.
public
incrementItem(string $key, int $value) : int|bool
Parameters
- $key : string
- $value : int
Tags
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
Return values
array<string|int, mixed> —Associative array of keys and new values
optimize()
Optimize the storage
public
optimize() : bool
Tags
Return values
bool —removeItem()
Remove an item.
public
removeItem(string $key) : bool
Parameters
- $key : string
Tags
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
Return values
array<string|int, mixed> —Array of not removed keys
removePlugin()
Unregister an already registered plugin
public
removePlugin(PluginInterface $plugin) : AbstractAdapter
Parameters
- $plugin : PluginInterface
Tags
Return values
AbstractAdapter —Provides a fluent interface
replaceItem()
Replace an existing item.
public
replaceItem(string $key, mixed $value) : bool
Parameters
- $key : string
- $value : mixed
Tags
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
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
Return values
AbstractAdapter —Provides a fluent interface
setItem()
Store an item.
public
setItem(string $key, mixed $value) : bool
Parameters
- $key : string
- $value : mixed
Tags
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
Return values
array<string|int, mixed> —Array of not stored keys
setOptions()
Set options.
public
setOptions(array<string|int, mixed>|Traversable|DbaOptions $options) : self
Parameters
- $options : array<string|int, mixed>|Traversable|DbaOptions
Tags
Return values
self —touchItem()
Reset lifetime of an item
public
touchItem(string $key) : bool
Parameters
- $key : string
Tags
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
Return values
array<string|int, mixed> —Array of not updated keys
_close()
Close database file if opened
protected
_close() : void
Return values
void —_open()
Open the database if not already done.
protected
_open() : void
Tags
Return values
void —internalAddItem()
Add an item.
protected
internalAddItem(string &$normalizedKey, mixed &$value) : bool
Parameters
- $normalizedKey : string
- $value : mixed
Tags
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
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
Return values
bool —internalDecrementItem()
Internal method to decrement an item.
protected
internalDecrementItem(string &$normalizedKey, int &$value) : int|bool
Parameters
- $normalizedKey : string
- $value : int
Tags
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
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
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
Return values
array<string|int, mixed> —Associative array of keys and values
internalGetMetadata()
Internal method to get metadata of an item.
protected
internalGetMetadata(string &$normalizedKey) : array<string|int, mixed>|bool
Parameters
- $normalizedKey : string
Tags
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
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
Tags
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>
Tags
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
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
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
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
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
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
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
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
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
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
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
Return values
void —normalizeKeys()
Validates and normalizes multiple keys
protected
normalizeKeys(array<string|int, mixed> &$keys) : void
Parameters
- $keys : array<string|int, mixed>
Tags
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
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
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