redis_phpKVDriver
extends jKVDriver
in package
implements
jIKVSet, jIKVttl
Tags
Interfaces, Classes and Traits
- jIKVSet
- jIKVttl
- interface for KV driver which support 'time to live' on values useful to use the driver as a cache storage
Table of Contents
- $_connection : object|resource
- Name of the driver.
- $_driverName : string
- Name of the driver.
- $_profile : array<string|int, mixed>
- Profile for the connection in the kvdb INIfile.
- $_profileName : string
- name of the profile
- $key_prefix : mixed
- $key_prefix_flush_method : mixed
- method to flush the keys when key_prefix is used
- __construct() : void
- Class constructor
- __destruct() : void
- Class destructor
- append() : string
- append a string to an existing key value
- decrement() : int
- decrement a value by $decr. the key should exist and should be an integer.
- delete() : bool
- Deletes a key from the KVdb.
- flush() : bool
- Flush the KVDb. Deletes all keys.
- garbage() : bool
- delete all keys which are not any more valid
- get() : string
- Gets one or several values;
- getRedis() : Redis
- hDel() : int|bool
- hExists() : bool
- hGet() : mixed|bool
- hGetAll() : array<string|int, string>
- hKeys() : array<string|int, string>
- hLen() : int|bool
- hMGet() : array<string|int, mixed>
- hMSet() : bool
- hSet() : int|bool
- hSetNx() : bool
- hStrLen() : mixed
- hVals() : array<string|int, string>
- increment() : int
- increment a value by $incr. the key should exist and should be an integer.
- insert() : bool
- Store a key/value. If the key already exist : error
- prepend() : string
- prepend a string to an existing key value
- replace() : bool
- Store a key/value. The key should exists
- sAdd() : mixed
- sCount() : mixed
- set() : bool
- Store a key/value.
- setWithTtl() : bool
- set a key/value with a ttl value
- sPop() : mixed
- sRemove() : mixed
- _connect() : Redis
- Connects to the redis server
- _disconnect() : mixed
- Disconnect from the redis server
- esc() : mixed
- getUsedKey() : mixed
- isResource() : mixed
- unesc() : mixed
Properties
$_connection
Name of the driver.
protected
object|resource
$_connection
=
ull
$_driverName
Name of the driver.
protected
string
$_driverName
$_profile
Profile for the connection in the kvdb INIfile.
protected
array<string|int, mixed>
$_profile
$_profileName
name of the profile
protected
string
$_profileName
$key_prefix
protected
mixed
$key_prefix
= ''
$key_prefix_flush_method
method to flush the keys when key_prefix is used
protected
mixed
$key_prefix_flush_method
= 'direct'
direct: uses SCAN and DEL, but it can take huge time jkvdbredisworker: it stores the keys prefix to delete into a redis list named 'jkvdbredisdelkeys'. You can use a script to launch a worker which pops from this list prefix of keys to delete, and delete them with SCAN/DEL redis commands. See the redisworker controller in the jelix module. event: send a jEvent. It's up to your application to respond to this event and to implement your prefered method to delete all keys.
Methods
__construct()
Class constructor
public
__construct(array<string|int, mixed> $profile) : void
Initialise profile data and create the main object
Parameters
- $profile : array<string|int, mixed>
Return values
void —__destruct()
Class destructor
public
__destruct() : void
Return values
void —append()
append a string to an existing key value
public
append(mixed $key, mixed $value) : string
Parameters
- $key : mixed
-
the key of the value to modify
- $value : mixed
-
the value to append to the current key value
Return values
string —the new value or false if failure
decrement()
decrement a value by $decr. the key should exist and should be an integer.
public
decrement(mixed $key[, mixed $decvalue = 1 ]) : int
Parameters
- $key : mixed
-
the key of the value
- $decvalue : mixed = 1
Return values
int —the result, or false if failure
delete()
Deletes a key from the KVdb.
public
delete(mixed $key) : bool
Parameters
- $key : mixed
-
the key
Return values
bool —false if failure
flush()
Flush the KVDb. Deletes all keys.
public
flush() : bool
Return values
bool —true if it is a success
garbage()
delete all keys which are not any more valid
public
garbage() : bool
Return values
bool —false if failure
get()
Gets one or several values;
public
get(mixed $key) : string
Parameters
- $key : mixed
-
a key or an array of keys
Return values
string —or null if the key doesn't exist
getRedis()
public
getRedis() : Redis
Return values
Redis —hDel()
public
hDel(string $key, string|array<string|int, string> $hKey) : int|bool
Parameters
- $key : string
- $hKey : string|array<string|int, string>
Return values
int|bool —the number of deleted keys, 0 if the key doesn't exist, FALSE if the key isn't a hash.
hExists()
public
hExists(string $key, string $hKey) : bool
Parameters
- $key : string
- $hKey : string
-
the hash key to check
Return values
bool —true if the hash key exists
hGet()
public
hGet(string $key, string $hKey) : mixed|bool
Parameters
- $key : string
- $hKey : string
-
the hash key to retrieve
Return values
mixed|bool —FALSE if it failed
hGetAll()
public
hGetAll(string $key) : array<string|int, string>
Parameters
- $key : string
Return values
array<string|int, string> —list of keys and values
hKeys()
public
hKeys(string $key) : array<string|int, string>
Parameters
- $key : string
Return values
array<string|int, string> —list of hkeys
hLen()
public
hLen(string $key) : int|bool
Parameters
- $key : string
Return values
int|bool —the number of items in a hash, FALSE if the key doesn't exist or isn't a hash.
hMGet()
public
hMGet(string $key, array<string|int, string> $keys) : array<string|int, mixed>
Parameters
- $key : string
- $keys : array<string|int, string>
-
list of hash keys to retrieve
Return values
array<string|int, mixed> —list of associative values
hMSet()
public
hMSet(string $key, array<string|int, mixed> $values) : bool
Parameters
- $key : string
- $values : array<string|int, mixed>
-
associative array with hkeys and values
Return values
bool —hSet()
public
hSet(string $key, string $hKey, mixed $value) : int|bool
Parameters
- $key : string
- $hKey : string
-
the hash key
- $value : mixed
Return values
int|bool —1 if value didn't exist and was added successfully, 0 if the value was already present and was replaced, FALSE if there was an error.
hSetNx()
public
hSetNx(string $key, string $hKey, mixed $value) : bool
Parameters
- $key : string
- $hKey : string
-
the hash key
- $value : mixed
Return values
bool —TRUE if it was set, FALSE if was already present
hStrLen()
public
hStrLen(string $key) : mixed
Parameters
- $key : string
Return values
mixed —hVals()
public
hVals(string $key) : array<string|int, string>
Parameters
- $key : string
Return values
array<string|int, string> —list of values (random order)
increment()
increment a value by $incr. the key should exist and should be an integer.
public
increment(mixed $key[, mixed $incvalue = 1 ]) : int
Parameters
- $key : mixed
-
the key of the value
- $incvalue : mixed = 1
Return values
int —the result, or false if failure
insert()
Store a key/value. If the key already exist : error
public
insert(mixed $key, mixed $value) : bool
Parameters
- $key : mixed
-
the key
- $value : mixed
Return values
bool —false if failure
prepend()
prepend a string to an existing key value
public
prepend(mixed $key, mixed $value) : string
Parameters
- $key : mixed
-
the key of the value to modify
- $value : mixed
-
the value to prepend to the current key value
Return values
string —the new value or false if failure
replace()
Store a key/value. The key should exists
public
replace(mixed $key, mixed $value) : bool
Parameters
- $key : mixed
-
the key
- $value : mixed
Return values
bool —false if failure
sAdd()
public
sAdd(mixed $skey, mixed $value) : mixed
Parameters
- $skey : mixed
- $value : mixed
Return values
mixed —sCount()
public
sCount(mixed $skey) : mixed
Parameters
- $skey : mixed
Return values
mixed —set()
Store a key/value.
public
set(mixed $key, mixed $value) : bool
Parameters
- $key : mixed
-
the key
- $value : mixed
Return values
bool —false if failure, if the value is a resource...
setWithTtl()
set a key/value with a ttl value
public
setWithTtl(mixed $key, mixed $value, mixed $ttl) : bool
Parameters
- $key : mixed
-
the key
- $value : mixed
-
the value
- $ttl : mixed
-
the time to live in seconds...
Return values
bool —false if failure, if the value is a resource...
sPop()
public
sPop(mixed $skey) : mixed
Parameters
- $skey : mixed
Return values
mixed —sRemove()
public
sRemove(mixed $skey, mixed $value) : mixed
Parameters
- $skey : mixed
- $value : mixed
Return values
mixed —_connect()
Connects to the redis server
protected
_connect() : Redis
Tags
Return values
Redis —object
_disconnect()
Disconnect from the redis server
protected
_disconnect() : mixed
Return values
mixed —esc()
protected
esc(mixed $val) : mixed
Parameters
- $val : mixed
Return values
mixed —getUsedKey()
protected
getUsedKey(mixed $key) : mixed
Parameters
- $key : mixed
Return values
mixed —isResource()
protected
isResource(mixed $value) : mixed
Parameters
- $value : mixed
Return values
mixed —unesc()
protected
unesc(mixed $val) : mixed
Parameters
- $val : mixed