fileKVDriver
extends jKVDriver
in package
implements
jIKVPersistent, jIKVttl
driver for jKVDb which store key values in files.
Tags
Interfaces, Classes and Traits
- jIKVPersistent
- interface for KV driver which store values in a persistent manner (in a file...).
- jIKVttl
- interface for KV driver which support 'time to live' on values useful to use the driver as a cache storage.
Table of Contents
- $automatic_cleaning_factor : int
- automatic cleaning process 0 means disabled, 1 means systematic cache cleaning of expired data (at each set or add call), greater values mean less frequent cleaning.
- $profil_name : string
- profil name used in the ini file.
- $_connection : object|resource
- Name of the driver.
- $_directory_level : int
- directory level.
- $_directory_umask : string
- umask for directory structure.
- $_driverName : string
- Name of the driver.
- $_file_locking : bool
- enable / disable locking file.
- $_profile : array<string|int, mixed>
- Profile for the connection in the kvdb INIfile.
- $_profileName : string
- name of the profile.
- $_storage_dir : string
- directory where to put the files.
- $file_umask : string
- umask for cache files.
- $keyPath : mixed
- __construct() : mixed
- Class constructor.
- __destruct() : mixed
- Class destructor.
- _connect() : mixed
- append() : bool
- append a string to an existing key value.
- decrement() : int
- decrement a specific data value by $var.
- delete() : bool
- delete a specific data.
- flush() : bool
- clear all data in the cache.
- garbage() : bool
- remove from the cache data of which TTL was expired.
- get() : mixed
- reads a specific data.
- increment() : int
- increment a specific data value by $var.
- insert() : bool
- insert new data.
- prepend() : bool
- prepend a string to an existing key value.
- replace() : bool
- replace a specific data.
- set() : bool
- set a specific data.
- setWithTtl() : bool
- set a specific data with a ttl.
- sync() : mixed
- synchronize the memory content with the persistent storage.
- _createDir() : mixed
- create a directory It creates also all necessary parent directory.
- _disconnect() : mixed
- _getFileContent() : mixed
- Reading in a file.
- _getFilePath() : string
- make and return a file name (with path).
- _isStored() : bool
- Check if exist a non expired stored file for the key $key.
- _removeDir() : mixed
- recursive function deleting a directory for the class.
- _setFileContent() : bool
- Writing in a file.
- isResource() : mixed
Properties
$automatic_cleaning_factor
automatic cleaning process 0 means disabled, 1 means systematic cache cleaning of expired data (at each set or add call), greater values mean less frequent cleaning.
public
int
$automatic_cleaning_factor
= 0
Tags
$profil_name
profil name used in the ini file.
public
string
$profil_name
Tags
$_connection
Name of the driver.
protected
object|resource
$_connection
Tags
$_directory_level
directory level.
protected
int
$_directory_level
= 2
Tags
$_directory_umask
umask for directory structure.
protected
string
$_directory_umask
= 0700
Tags
$_driverName
Name of the driver.
protected
string
$_driverName
Tags
$_file_locking
enable / disable locking file.
protected
bool
$_file_locking
= \true
Tags
$_profile
Profile for the connection in the kvdb INIfile.
protected
array<string|int, mixed>
$_profile
Tags
$_profileName
name of the profile.
protected
string
$_profileName
Tags
$_storage_dir
directory where to put the files.
protected
string
$_storage_dir
Tags
$file_umask
umask for cache files.
protected
string
$file_umask
= 0600
Tags
$keyPath
protected
mixed
$keyPath
= array()
Tags
Methods
__construct()
Class constructor.
public
__construct(array<string|int, mixed> $profile) : mixed
Initialise profile data and create the main object
Parameters
- $profile : array<string|int, mixed>
Tags
Return values
mixed —__destruct()
Class destructor.
public
__destruct() : mixed
Tags
Return values
mixed —_connect()
public
_connect() : mixed
Tags
Return values
mixed —append()
append a string to an existing key value.
public
append(string $key, string $value) : bool
Parameters
- $key : string
-
the key of the value to modify
- $value : string
-
the value to append to the current key value
Tags
Return values
bool —false if failure
decrement()
decrement a specific data value by $var.
public
decrement(string $key[, mixed $var = 1 ]) : int
Parameters
- $key : string
-
key used for storing data in the cache
- $var : mixed = 1
-
value used
Tags
Return values
int —the result, or false if failure
delete()
delete a specific data.
public
delete(string $key) : bool
Parameters
- $key : string
-
key used for storing data in the cache
Tags
Return values
bool —false if failure
flush()
clear all data in the cache.
public
flush() : bool
Tags
Return values
bool —false if failure
garbage()
remove from the cache data of which TTL was expired.
public
garbage() : bool
Tags
Return values
bool —false if failure
get()
reads a specific data.
public
get(mixed $key) : mixed
Parameters
- $key : mixed
-
key or array of keys used for storing data
Tags
Return values
mixed —$data data or null if failure
increment()
increment a specific data value by $var.
public
increment(string $key[, mixed $var = 1 ]) : int
Parameters
- $key : string
-
key used for storing data in the cache
- $var : mixed = 1
-
value used
Tags
Return values
int —the result, or false if failure
insert()
insert new data.
public
insert(string $key, mixed $value) : bool
Parameters
- $key : string
-
key used for storing data
- $value : mixed
-
data to store
Tags
Return values
bool —false if failure
prepend()
prepend a string to an existing key value.
public
prepend(string $key, string $value) : bool
Parameters
- $key : string
-
the key of the value to modify
- $value : string
-
the value to prepend to the current key value
Tags
Return values
bool —false if failure
replace()
replace a specific data.
public
replace(string $key, mixed $value) : bool
Parameters
- $key : string
-
key used for storing data
- $value : mixed
-
data to store
Tags
Return values
bool —false if failure
set()
set a specific data.
public
set(string $key, mixed $value) : bool
Parameters
- $key : string
-
key used for storing data
- $value : mixed
-
data to store
Tags
Return values
bool —false if failure
setWithTtl()
set a specific data with a ttl.
public
setWithTtl(string $key, mixed $var, int $ttl) : bool
Parameters
- $key : string
-
key used for storing data
- $var : mixed
-
data to store
- $ttl : int
-
time to live, in seconds
Tags
Return values
bool —false if failure
sync()
synchronize the memory content with the persistent storage.
public
sync() : mixed
Tags
Return values
mixed —_createDir()
create a directory It creates also all necessary parent directory.
protected
_createDir(string $dir) : mixed
Parameters
- $dir : string
-
the path of the directory
Tags
Return values
mixed —_disconnect()
protected
_disconnect() : mixed
Tags
Return values
mixed —_getFileContent()
Reading in a file.
protected
_getFileContent(mixed $filePath) : mixed
Parameters
- $filePath : mixed
Tags
Return values
mixed —return file content or null if failure
_getFilePath()
make and return a file name (with path).
protected
_getFilePath(string $key) : string
Parameters
- $key : string
-
the key
Tags
Return values
string —File name (with path)
_isStored()
Check if exist a non expired stored file for the key $key.
protected
_isStored(string $key) : bool
Parameters
- $key : string
-
key used for the specific data
Tags
Return values
bool —_removeDir()
recursive function deleting a directory for the class.
protected
_removeDir(string $dir[, bool $all = true ][, mixed $deleteParent = true ]) : mixed
Parameters
- $dir : string
-
the path of the directory to remove recursively
- $all : bool = true
-
directory deleting mode. If true delete all else delete files expired
- $deleteParent : mixed = true
Tags
Return values
mixed —_setFileContent()
Writing in a file.
protected
_setFileContent(string $filePath, mixed $dataToWrite, int $mtime) : bool
Parameters
- $filePath : string
-
file name
- $dataToWrite : mixed
- $mtime : int
-
modification time
Tags
Return values
bool —true if success of writing operation
isResource()
protected
isResource(mixed $value) : mixed
Parameters
- $value : mixed