redis_phpKVDriver

Extends \jKVDriver Implements \jIKVSet, \jIKVttl

package

jelix

subpackage

kvdb_plugin

author

Yannick Le Guédart

contributor

Laurent Jouanneau

copyright

2009 Yannick Le Guédart, 2010-2016 Laurent Jouanneau

link

http://www.jelix.org

licence

http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file

Methods

Class constructor

__construct(array $profile) : void
inherited

Initialise profile data and create the main object

Arguments

$profile

array

Class destructor

__destruct() : void
inherited

_connect

_connect() 
inherited abstract

_disconnect

_disconnect() 
inherited abstract

append a string to an existing key value

append(string $key, string $value) : string
inherited abstract

Arguments

$key

string

the key of the value to modify

$value

string

the value to append to the current key value

Response

string

the new value or false if failure

decrement a value by $decr. the key should exist and should be an integer.

decrement(string $key, mixed $decr = 1) : integer
inherited abstract

Arguments

$key

string

the key of the value

$decr

mixed

the value to substract to the current value

Response

integer

the result, or false if failure

Deletes a key from the KVdb.

delete(string $key) : boolean
inherited abstract

Arguments

$key

string

the key

Response

boolean

false if failure

esc

esc( $val) 

Arguments

$val

Flush the KVDb. Deletes all keys.

flush() : boolean
inherited abstract

Response

boolean

true if it is a success

delete all keys which are not any more valid

garbage() : boolean

Response

boolean

false if failure

Gets one or several values;

get(string|array $key) : string
inherited abstract

Arguments

$key

string|array

a key or an array of keys

Response

string

or null if the key doesn't exist

getRedis

getRedis() : \PhpRedis\Redis

Response

\PhpRedis\Redis

getUsedKey

getUsedKey( $key) 

Arguments

$key

hDel

hDel(string $key, string|array<mixed,string> $hKey) : integer|boolean

Arguments

$key

string

$hKey

string|array<mixed,string>

Response

integer|boolean

the number of deleted keys, 0 if the key doesn't exist, FALSE if the key isn't a hash.

hExists

hExists(string $key, string $hKey) : boolean

Arguments

$key

string

$hKey

string

the hash key to check

Response

boolean

true if the hash key exists

hGet

hGet(string $key, string $hKey) : mixed|boolean

Arguments

$key

string

$hKey

string

the hash key to retrieve

Response

mixed|boolean

FALSE if it failed

hGetAll

hGetAll(string $key) : array<mixed,string>

Arguments

$key

string

Response

array<mixed,string>

list of keys and values

hKeys

hKeys(string $key) : array<mixed,string>

Arguments

$key

string

Response

array<mixed,string>

list of hkeys

hLen

hLen(string $key) : integer|boolean

Arguments

$key

string

Response

integer|boolean

the number of items in a hash, FALSE if the key doesn't exist or isn't a hash.

hMGet

hMGet(string $key, array<mixed,string> $keys) : array

Arguments

$key

string

$keys

array<mixed,string>

list of hash keys to retrieve

Response

array

list of associative values

hMSet

hMSet(string $key, array $values) : boolean

Arguments

$key

string

$values

array

associative array with hkeys and values

Response

boolean

hSet

hSet(string $key, string $hKey, mixed $value) : integer|boolean

Arguments

$key

string

$hKey

string

the hash key

$value

mixed

Response

integer|boolean

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

hSetNx(string $key, string $hKey, mixed $value) : boolean

Arguments

$key

string

$hKey

string

the hash key

$value

mixed

Response

boolean

TRUE if it was set, FALSE if was already present

hStrLen

hStrLen(string $key) : mixed

Arguments

$key

string

Response

mixed

hVals

hVals(string $key) : array<mixed,string>

Arguments

$key

string

Response

array<mixed,string>

list of values (random order)

increment a value by $incr. the key should exist and should be an integer.

increment(string $key, mixed $incr = 1) : integer
inherited abstract

Arguments

$key

string

the key of the value

$incr

mixed

the value to add to the current value

Response

integer

the result, or false if failure

Store a key/value. If the key already exist : error

insert(string $key, string $value) : boolean
inherited abstract

Arguments

$key

string

the key

$value

string

Response

boolean

false if failure

prepend a string to an existing key value

prepend(string $key, string $value) : string
inherited abstract

Arguments

$key

string

the key of the value to modify

$value

string

the value to prepend to the current key value

Response

string

the new value or false if failure

Store a key/value. The key should exists

replace(string $key, string $value) : boolean
inherited abstract

Arguments

$key

string

the key

$value

string

Response

boolean

false if failure

sAdd

sAdd( $skey,  $value) 

Arguments

$skey

$value

sCount

sCount( $skey) 

Arguments

$skey

Store a key/value.

set(string $key, string $value) : boolean
inherited abstract

Arguments

$key

string

the key

$value

string

Response

boolean

false if failure, if the value is a resource...

set a key/value with a ttl value

setWithTtl(string $key, string $value, integer $ttl) : boolean

Arguments

$key

string

the key

$value

string

the value

$ttl

integer

the time to live in seconds...

Response

boolean

false if failure, if the value is a resource...

sPop

sPop( $skey) 

Arguments

$skey

sRemove

sRemove( $skey,  $value) 

Arguments

$skey

$value

unesc

unesc( $val) 

Arguments

$val

Properties

key_prefix

key_prefix : 

Type(s)

method to flush the keys when key_prefix is used

key_prefix_flush_method : 

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.

Type(s)

Profile for the connection in the kvdb INIfile.

_profile : array
inherited
var

Type(s)

array

Name of the driver.

_driverName : string
inherited
var

Type(s)

string

name of the profile

_profileName : string
inherited
var

Type(s)

string

Name of the driver.

_connection : object|resource
inherited
var

Type(s)

object|resource