Jelix 1.6.40

dbKVDriver extends jKVDriver
in package
implements jIKVttl, jIKVPersistent

Driver for jKVDB, that uses an SQL table to store key/value data.

Interfaces, Classes and Traits

jIKVttl
interface for KV driver which support 'time to live' on values useful to use the driver as a cache storage
jIKVPersistent
interface for KV driver which store values in a persistent manner (in a file...)

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
$table  : mixed
__construct()  : void
Class constructor
__destruct()  : void
Class destructor
_set()  : mixed
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;
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
set()  : bool
Store a key/value.
setWithTtl()  : bool
set a key/value with a ttl value
sync()  : mixed
synchronize the memory content with the persistent storage
_connect()  : mixed
_disconnect()  : mixed
isResource()  : mixed

Properties

$_connection

Name of the driver.

protected object|resource $_connection = ull

$_profile

Profile for the connection in the kvdb INIfile.

protected array<string|int, mixed> $_profile

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

_set()

public _set(mixed $key, mixed $value, mixed $expire) : mixed
Parameters
$key : mixed
$value : mixed
$expire : mixed
Return values
mixed

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 $decr = 1 ]) : int
Parameters
$key : mixed

the key of the value

$decr : mixed = 1

the value to substract to the current value

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

increment()

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

public increment(mixed $key[, mixed $incr = 1 ]) : int
Parameters
$key : mixed

the key of the value

$incr : mixed = 1

the value to add to the current value

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

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(string $key, string $value, int $ttl) : bool
Parameters
$key : string

the key

$value : string

the value

$ttl : int

the time to live in seconds...

Return values
bool

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

sync()

synchronize the memory content with the persistent storage

public sync() : mixed
Return values
mixed

_connect()

protected _connect() : mixed
Return values
mixed

_disconnect()

protected _disconnect() : mixed
Return values
mixed

isResource()

protected isResource(mixed $value) : mixed
Parameters
$value : mixed
Return values
mixed

Search results