Documentation

Horde_HashTable_Predis extends Horde_HashTable_Base
in package
implements Horde_HashTable_Lock

Implementation of HashTable for a Redis server (using the Predis library).

See: https://github.com/nrk/predis

Tags
author

Michael Slusarz slusarz@horde.org

category

Horde

copyright

2013-2017 Horde LLC

license

http://www.horde.org/licenses/lgpl21 LGPL 2.1

Interfaces, Classes, Traits and Enums

Horde_HashTable_Lock
Extension to base HashTable class by adding lock methods to prevent access from other PHP processes.

Table of Contents

LOCK_SUFFIX  = '_l'
LOCK_TIMEOUT  = 30
$locking  : bool
$persistent  : bool
$prefix  : string
$_locks  : array<string|int, mixed>
Locked keys.
$_noexist  : array<string|int, mixed>
A list of items known not to exist.
$_params  : array<string|int, mixed>
Configuration parameters.
$_persistent  : bool
Persistent storage provided by driver?
$_predis  : Client
Predis client object.
__construct()  : mixed
Constructor.
__get()  : mixed
__set()  : mixed
clear()  : mixed
Clear all hash table entries.
delete()  : bool
Delete a key(s).
exists()  : mixed
Do the keys exists?
get()  : mixed
Get data associated with a key(s).
hkey()  : string
Add local prefix to beginning of key.
lock()  : mixed
Obtain lock on a key.
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
serialize()  : mixed
set()  : bool
Set the value of a key.
shutdown()  : mixed
Shutdown function.
unlock()  : mixed
Release lock on a key.
unserialize()  : mixed
_delete()  : bool
Delete keys.
_exists()  : array<string|int, mixed>
Get data associated with keys.
_get()  : array<string|int, mixed>
Get data associated with keys.
_getExists()  : mixed
Does a get/exists action on a set of keys.
_init()  : mixed
Do initialization.
_set()  : bool
Set the value of a key.

Constants

LOCK_SUFFIX

public mixed LOCK_SUFFIX = '_l'

LOCK_TIMEOUT

public mixed LOCK_TIMEOUT = 30

Properties

$locking read-only

public bool $locking

Does hash table provide locking? (@since 1.1.0)

$persistent read-only

public bool $persistent

Does hash table provide persistent storage?

$prefix write-only

public string $prefix

Set the hash key prefix.

$_locks

Locked keys.

protected array<string|int, mixed> $_locks = array()

$_noexist

A list of items known not to exist.

protected array<string|int, mixed> $_noexist = array()

$_params

Configuration parameters.

protected array<string|int, mixed> $_params = array('prefix' => 'hht_')

$_persistent

Persistent storage provided by driver?

protected bool $_persistent = \false

$_predis

Predis client object.

protected Client $_predis

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $params = array() ]) : mixed
Parameters
$params : array<string|int, mixed> = array()

Additional configuration parameters:

  - predis: (Predis\Client) [REQUIRED] Predis client object.
Return values
mixed

__get()

public __get(mixed $name) : mixed
Parameters
$name : mixed
Return values
mixed

__set()

public __set(mixed $name, mixed $val) : mixed
Parameters
$name : mixed
$val : mixed
Return values
mixed

clear()

Clear all hash table entries.

public clear() : mixed
Return values
mixed

delete()

Delete a key(s).

public delete(mixed $keys) : bool
Parameters
$keys : mixed

The key or an array of keys to delete.

Return values
bool

True on success.

exists()

Do the keys exists?

public exists(mixed $keys) : mixed
Parameters
$keys : mixed

The key or an array of keys.

Return values
mixed

A boolean/array of booleans indicating existence (return type is the type of $keys).

get()

Get data associated with a key(s).

public get(mixed $keys) : mixed
Parameters
$keys : mixed

The key or an array of keys.

Return values
mixed

The string/array on success (return type is the type of $keys); false value(s) on failure.

hkey()

Add local prefix to beginning of key.

public hkey(mixed $key) : string
Parameters
$key : mixed

Key name.

Return values
string

Hash table key identifier.

lock()

Obtain lock on a key.

public lock(mixed $key) : mixed
Parameters
$key : mixed

The key to lock.

Return values
mixed

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetSet()

public offsetSet(mixed $offset, mixed $value) : mixed
Parameters
$offset : mixed
$value : mixed
Return values
mixed

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

serialize()

public serialize() : mixed
Return values
mixed

set()

Set the value of a key.

public set(string $key, string $val[, array<string|int, mixed> $opts = array() ]) : bool
Parameters
$key : string

The key.

$val : string

The string to store.

$opts : array<string|int, mixed> = array()

Additional options:

  - expire: (integer) Expiration time in seconds.
            DEFAULT: Doesn't expire.
  - replace: (boolean) Replace the value of key. If key doesn't exist,
             returns false.
             DEFAULT: false
Return values
bool

True on success, false on error.

shutdown()

Shutdown function.

public shutdown() : mixed
Return values
mixed

unlock()

Release lock on a key.

public unlock(mixed $key) : mixed
Parameters
$key : mixed

The key to lock.

Return values
mixed

unserialize()

public unserialize(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

_delete()

Delete keys.

protected _delete(mixed $keys) : bool
Parameters
$keys : mixed
Return values
bool

True on success.

_exists()

Get data associated with keys.

protected _exists(mixed $keys) : array<string|int, mixed>
Parameters
$keys : mixed

An array of keys.

Return values
array<string|int, mixed>

Existence check. Values are boolean true/false.

_get()

Get data associated with keys.

protected _get(mixed $keys) : array<string|int, mixed>
Parameters
$keys : mixed

An array of keys.

Return values
array<string|int, mixed>

The retrieved keys. Non-existent keys should return false as the value.

_getExists()

Does a get/exists action on a set of keys.

protected _getExists(mixed $keys, callable $callback) : mixed
Parameters
$keys : mixed

The key or an array of keys.

$callback : callable

The internal callback action.

Return values
mixed

The results.

_init()

Do initialization.

protected _init() : mixed
Return values
mixed

_set()

Set the value of a key.

protected _set(mixed $key, mixed $val, mixed $opts) : bool
Parameters
$key : mixed

The key.

$val : mixed

The string to store.

$opts : mixed

Additional options (see set()).

Return values
bool

True on success.

Search results