fileCacheDriver
in package
implements
jICacheDriver
cache driver for data stored in a file.
Tags
Interfaces, Classes and Traits
- jICacheDriver
- Interface for cache drivers.
Table of Contents
- CACHEEXT = '.cache'
- extension to use for cache files.
- $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.
- $enabled : bool
- active cache ?
- $profil_name : string
- profil name used in the ini file.
- $ttl : bool
- TTL used.
- $_cache_dir : string
- directory where to put the cache files.
- $_cache_file_umask : string
- umask for cache files.
- $_directory_level : int
- directory level.
- $_directory_umask : string
- umask for directory structure.
- $_file_locking : bool
- enable / disable locking file.
- $_file_name_prefix : string
- prefix for cache files.
- __construct() : mixed
- constructor.
- decrement() : bool
- decrement a specific data value by $var.
- delete() : bool
- delete a specific data in the cache.
- flush() : bool
- clear all data in the cache.
- garbage() : bool
- remove from the cache data of which TTL was expired.
- get() : mixed
- read a specific data in the cache.
- increment() : bool
- increment a specific data value by $var.
- replace() : bool
- replace a specific data value by $var.
- set() : bool
- set a specific data in the cache.
- _createDir() : mixed
- create a directory It creates also all necessary parent directory.
- _getCacheFilePath() : string
- make and return a file name (with path).
- _getFileContent() : mixed
- Reading in a file.
- _getPath() : string
- return the complete directory path.
- _isCached() : bool
- Check if exist a non expired cache file for the key $key.
- _removeDir() : mixed
- recursive function deleting a directory for the class.
- _setFileContent() : bool
- Writing in a file.
Constants
CACHEEXT
extension to use for cache files.
public
string
CACHEEXT
= '.cache'
Tags
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
$enabled
active cache ?
public
bool
$enabled
= \true
Tags
$profil_name
profil name used in the ini file.
public
string
$profil_name
Tags
$ttl
TTL used.
public
bool
$ttl
= 0
Tags
$_cache_dir
directory where to put the cache files.
protected
string
$_cache_dir
Tags
$_cache_file_umask
umask for cache files.
protected
string
$_cache_file_umask
= 0600
Tags
$_directory_level
directory level.
protected
int
$_directory_level
= 0
Tags
$_directory_umask
umask for directory structure.
protected
string
$_directory_umask
= 0700
Tags
$_file_locking
enable / disable locking file.
protected
bool
$_file_locking
= \true
Tags
$_file_name_prefix
prefix for cache files.
protected
string
$_file_name_prefix
= 'jelix_cache'
Tags
Methods
__construct()
constructor.
public
__construct(mixed $params) : mixed
Parameters
- $params : mixed
-
driver parameters, written in the ini file
Tags
Return values
mixed —decrement()
decrement a specific data value by $var.
public
decrement(string $key[, mixed $var = 1 ]) : bool
Parameters
- $key : string
-
key used for storing data in the cache
- $var : mixed = 1
-
value used
Tags
Return values
bool —false if failure
delete()
delete a specific data in the cache.
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()
read a specific data in the cache.
public
get(mixed $key) : mixed
Parameters
- $key : mixed
-
key or array of keys used for storing data in the cache
Tags
Return values
mixed —$data data or false if failure
increment()
increment a specific data value by $var.
public
increment(string $key[, mixed $var = 1 ]) : bool
Parameters
- $key : string
-
key used for storing data in the cache
- $var : mixed = 1
-
value used
Tags
Return values
bool —false if failure
replace()
replace a specific data value by $var.
public
replace(string $key, mixed $var, int $ttl) : bool
Parameters
- $key : string
-
key used for storing data in the cache
- $var : mixed
-
data to replace
- $ttl : int
-
data time expiration
Tags
Return values
bool —false if failure
set()
set a specific data in the cache.
public
set(string $key, mixed $var, int $ttl) : bool
Parameters
- $key : string
-
key used for storing data
- $var : mixed
-
data to store
- $ttl : int
-
data time expiration
Tags
Return values
bool —false if failure
_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 —_getCacheFilePath()
make and return a file name (with path).
protected
_getCacheFilePath(string $key) : string
Parameters
- $key : string
-
Cache key
Tags
Return values
string —File name (with path)
_getFileContent()
Reading in a file.
protected
_getFileContent(mixed $filePath) : mixed
Parameters
- $filePath : mixed
Tags
Return values
mixed —return file content or null if failure
_getPath()
return the complete directory path.
protected
_getPath(string $key) : string
Parameters
- $key : string
-
Cache key
Tags
Return values
string —directory path
_isCached()
Check if exist a non expired cache file for the key $key.
protected
_isCached(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) : bool
Parameters
- $filePath : string
-
file name
- $dataToWrite : mixed
Tags
Return values
bool —true if success of writing operation