Menu

## FileCache extends Cache
in package

FileCache.php : 22

This class provides functionality for caching data to the filesystem.

##### Tags

see
  https://www.kotchasan.com/

### Table of Contents

$cache_dir : string
  Cache directory path
$cache_expire : int
  Cache expiration time in seconds (0 means no cache)
$cfg : object
  Config class instance.
$deferred : array<string|int, mixed>
  Deferred cache items
$request : Request
  Server request class instance.
__construct() : mixed
  Class constructor
clear() : bool
  Clear the cache
commit() : bool
  Commit the cached items in the deferred queue
deleteItem() : bool
  Delete a cache item
deleteItems() : bool
  Delete multiple cache items
getItem() : CacheItemInterface
  Get a cache item
getItems() : array<string|int, mixed>
  Get multiple cache items
hasItem() : bool
  Check if a cache item exists
save() : bool
  Save a cache item
saveDeferred() : bool
  Save a cache item for deferred saving
clearCache() : mixed
  Clear all files in the cache directory
fetchStreamUri() : string
  Get the full path of the cache file
isExpired() : bool
  Check if a cache file has expired

### Properties

#### $cache_dir

FileCache.php : 29

Cache directory path

`protected string $cache_dir = null`

/root/to/dir/cache/

#### $cache_expire

FileCache.php : 35

Cache expiration time in seconds (0 means no cache)

`protected int $cache_expire = 0`

#### $cfg

KBase.php : 26

Config class instance.

`protected static object $cfg`

#### $deferred

Cache.php : 31

Deferred cache items

`protected array<string|int, mixed> $deferred = []`

#### $request

KBase.php : 33

Server request class instance.

`protected static Request $request`

### Methods

#### __construct()

FileCache.php : 42

Class constructor

`public __construct() : mixed`

##### Tags

throws
  Exception

  if the cache directory cannot be created

##### Return values

mixed —

#### clear()

FileCache.php : 71

Clear the cache

`public clear() : bool`

##### Return values

bool —

true if the cache is cleared successfully, false otherwise

#### commit()

Cache.php : 38

Commit the cached items in the deferred queue

`public commit() : bool`

##### Return values

bool —

#### deleteItem()

Cache.php : 56

Delete a cache item

`public deleteItem(string $key) : bool`

##### Parameters

$key : string

##### Return values

bool —

#### deleteItems()

FileCache.php : 87

Delete multiple cache items

`public deleteItems(array<string|int, mixed> $keys) : bool`

##### Parameters

$keys : array<string|int, mixed>

##### Return values

bool —

true if the deletion is successful, false otherwise

#### getItem()

Cache.php : 68

Get a cache item

`public getItem(string $key) : CacheItemInterface`

##### Parameters

$key : string

##### Return values

CacheItemInterface —

#### getItems()

FileCache.php : 104

Get multiple cache items

`public getItems([array<string|int, mixed> $keys = [] ]) : array<string|int, mixed>`

##### Parameters

$keys : array<string|int, mixed> = []

##### Return values

array<string|int, mixed> —

#### hasItem()

FileCache.php : 124

Check if a cache item exists

`public hasItem(string $key) : bool`

##### Parameters

$key : string

##### Return values

bool —

#### save()

FileCache.php : 138

Save a cache item

`public save(CacheItemInterface $item) : bool`

##### Parameters

$item : CacheItemInterface

##### Tags

throws
  Exception

  if the cache file cannot be created

##### Return values

bool —

true if the cache item is saved successfully, false otherwise

#### saveDeferred()

Cache.php : 81

Save a cache item for deferred saving

`public saveDeferred(CacheItemInterface $item) : bool`

##### Parameters

$item : CacheItemInterface

##### Return values

bool —

#### clearCache()

FileCache.php : 159

Clear all files in the cache directory

`private clearCache(string $dir, array<string|int, mixed> &$error) : mixed`

##### Parameters

$dir : string
$error : array<string|int, mixed>

##### Return values

mixed —

#### fetchStreamUri()

FileCache.php : 185

Get the full path of the cache file

`private fetchStreamUri(string $key) : string`

##### Parameters

$key : string

##### Return values

string —

#### isExpired()

FileCache.php : 197

Check if a cache file has expired

`private isExpired(string $file) : bool`

##### Parameters

$file : string

##### Return values

bool —

## Search results