\Rundiz\SimpleCache\DriversFileSystem

File system driver.

Summary

Methods
Properties
Constants
deleteMultiple()
getMultiple()
setMultiple()
__construct()
clear()
delete()
get()
has()
set()
No public properties found
No constants found
createFolderIfNotExists()
deleteCacheSubfolderRecursively()
deleteCacheSubfoldersIfEmpty()
keyToPathAndFileName()
sanitizeFileName()
$cachePath
$umask
N/A
No private methods found
No private properties found
N/A

Properties

$cachePath

$cachePath : string

Full path to cache directory.

Type

string — Path to cache directory.

$umask

$umask : integer

umask

Type

integer

Methods

deleteMultiple()

deleteMultiple(  $keys) 

{@inheritDoc}

Parameters

$keys

getMultiple()

getMultiple(  $keys,   $default = null) 

{@inheritDoc}

Parameters

$keys
$default

setMultiple()

setMultiple(  $values,   $ttl = null) 

{@inheritDoc}

Parameters

$values
$ttl

__construct()

__construct(string  $cachePath = '', integer  $umask = 2) 

Class constructor

Parameters

string $cachePath

Path to cache folder. It will be automatically create if not exists or throw an error if it stuck at some where.

integer $umask

See more at http://php.net/manual/en/function.umask.php

Throws

\Exception

clear()

clear() 

{@inheritDoc}

delete()

delete(  $key) 

{@inheritDoc}

Parameters

$key

get()

get(  $key,   $default = null) 

{@inheritDoc}

Parameters

$key
$default

has()

has(  $key) 

{@inheritDoc}

Parameters

$key

set()

set(  $key,   $value,   $ttl = null) 

{@inheritDoc}

Parameters

$key
$value
$ttl

createFolderIfNotExists()

createFolderIfNotExists(string  $cachePath) : boolean

Create folder or path if it is not exists.

This method was called from __construct(), set().

Parameters

string $cachePath

Path to check and create.

Returns

boolean —

Return true if exists or created, return false for otherwise.

deleteCacheSubfolderRecursively()

deleteCacheSubfolderRecursively(string  $dir) 

Delete cache files and all sub folders recursively.

This method was called from clear().

Parameters

string $dir

Path to main cache folder.

deleteCacheSubfoldersIfEmpty()

deleteCacheSubfoldersIfEmpty(string  $filepath) : boolean

Delete cache sub folder (recursively using `\FilesystemIterator`) if empty.

This method was called from delete().

Parameters

string $filepath

Path to cache sub folder.

Returns

boolean —

Return true on success, false if there is something error.

keyToPathAndFileName()

keyToPathAndFileName(string  $key) : string

Convert key to path and file name.

For example: If key is "accounts.model.get_user_1" then it will be convert to accounts/model/get_user_1/md5(key)

This method was called from get(), set(), delete().

Parameters

string $key

The cache key

Returns

string —

Return the cache subfolders (if dot in the cache key exists) with file cache file name.

sanitizeFileName()

sanitizeFileName(string  $string, boolean  $forceLowerCase = false) : string

Returns a sanitized string, typically for URLs.

This method was called from keyToPathAndFileName().

Parameters

string $string

The string to sanitize.

boolean $forceLowerCase

Set to true to force the string to lowercase

Returns

string —

Sanitized string.