FilesCache class

Framework\Cache\FilesCache

Class FilesCache.

Extends Framework\Cache\Cache

Defined in libraries/cache/src/FilesCache.php

Properties #

$configs
Files Cache handler configurations.
$baseDirectory
-

$configs

protected array $configs = array ( 'directory' => NULL, 'files_permission' => 420, 'gc' => 1, )

Files Cache handler configurations.

$baseDirectory

protected ?string $baseDirectory

Methods #

__construct()
FilesCache constructor.
__destruct()
-
delete()
-
flush()
-
gc()
Garbage collector.
get()
-
set()
-
setValue()
-
closeDir()
-
createSubDirectory()
-
deleteAll()
-
deleteExpired()
-
deleteFile()
-
getContents()
-
initialize()
-
openDir()
-
renderFilepath()
-
setBaseDirectory()
-
setGC()
-

__construct()

public function __construct(?array $configs = array ( ), ?string $prefix = NULL, \Framework\Cache\Serializer|string $serializer = \Framework\Cache\Serializer::PHP, ?\Framework\Log\Logger $logger = NULL)

FilesCache constructor.

Parameters
  • ?array $configs - Driver specific configurations
  • ?string $prefix - Keys prefix
  • \Framework\Cache\Serializer|string $serializer - Data serializer
  • ?\Framework\Log\Logger $logger - Logger instance

__destruct()

public function __destruct()

delete()

public function delete(string $key): bool
Parameters
  • string $key
Returns bool

flush()

public function flush(): bool
Returns bool

gc()

public function gc(): bool

Garbage collector.

Deletes all expired items.

Returns bool - TRUE if all expired items was deleted, FALSE if a fail occurs

get()

public function get(string $key): mixed
Parameters
  • string $key
Returns mixed

set()

public function set(string $key, mixed $value, ?int $ttl = NULL): bool
Parameters
  • string $key
  • mixed $value
  • ?int $ttl
Returns bool

setValue()

public function setValue(string $key, mixed $value, ?int $ttl = NULL): bool
Parameters
  • string $key
  • mixed $value
  • ?int $ttl
Returns bool

closeDir()

protected function closeDir($resource): void
Parameters
  • resource $resource
Returns void

createSubDirectory()

protected function createSubDirectory(string $filepath): void
Parameters
  • string $filepath
Returns void

deleteAll()

protected function deleteAll(string $baseDirectory): bool
Parameters
  • string $baseDirectory
Returns bool

deleteExpired()

protected function deleteExpired(string $baseDirectory): bool
Parameters
  • string $baseDirectory
Returns bool

deleteFile()

protected function deleteFile(string $filepath): bool
Parameters
  • string $filepath
Returns bool

getContents()

protected function getContents(string $filepath): mixed
Parameters
  • string $filepath
Returns mixed

initialize()

protected function initialize(): void
Returns void

openDir()

protected function openDir(string $dirpath)
Parameters
  • string $dirpath
Returns false|resource

renderFilepath()

protected function renderFilepath(string $key): string
Parameters
  • string $key
Returns string

setBaseDirectory()

protected function setBaseDirectory(): void
Returns void

setGC()

protected function setGC(int $gc): void
Parameters
  • int $gc
Returns void

Inherited methods #