File
About 1 min
File
The file cache backend.
This backend will cache data to the filesystem. It is basically a "works all the time" backend that is available regardless of what modules are installed or server software is available. It is very handing for using caching on systems where no other cache backends are available.
Available config options:
- cache_dir - The directory to store cache files in. Default is to use a 'cache' directory in the application .runtime directory.
- file_prefix - This is an optional prefix to apply to the cache files. Useful if you want to separate your cache files. Default: no prefix
- use_zlib - Enable or disable zlib compression on the cache files. This can slow things down quite a bit more, but is useful when you
- encode_fs - Encodes the filesystem files using an md5 hash to obscure file namespaces on disk are caching very large things. I wouldn't bother using it under normal circumstances. Default: false.
Properties
weight
protected int $weight = 4
zlib
private bool $zlib
cacheDir
private string $cacheDir
timeout
private int $timeout
local
private array $local
store
private BTree $store
__openStore
private array $__openStore
Methods
__destruct
Store the namespace timeout in the cache dir timeout file.
public __destruct(): void
This should only happen if a keepalive() has been called.
available
public available(): bool
init
public init(string $namespace): void
Parameters
Parameter | Type | Description |
---|---|---|
$namespace | string |
has
Check if a value exists.
public has(string $key, bool $check_empty = false): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | |
$check_empty | bool |
get
public get(string $key): mixed
Parameters
Parameter | Type | Description |
---|---|---|
$key | string |
set
public set(string $key, mixed $value, ?int $timeout = 0): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | |
$value | mixed | |
$timeout | int |
remove
public remove(string $key): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string |
clear
public clear(): bool
toArray
public toArray(): void
count
public count(): int
keepalive
private keepalive(): void
load
Load the key value from storage.
private load(string $key, ?array $cache): mixed
This should only happen once and then it will be stored in memory and only written again when changed.
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | |
$cache | array |
Generated by Hazaar API Doc Generator