FileStorage

Extends CacheStorage

File cache storage handler

since

1.7.0

note

For performance reasons this class does not use the Filesystem package's API

package

Joomla CMS

Methods

__construct

Constructor

__construct(mixed||string|int options = []) : 
since

1.7.0

Arguments

options

array<string|int, mixed>Optional parameters

Response

mixed

_checkExpire

Check if a cache object has expired

_checkExpire( id,  group) : 

Using @ error suppressor here because between if we did a file_exists() and then filemsize() there will be a little time space when another process can delete the file and then you get PHP Warning

since

1.7.0

Arguments

id

stringCache ID to check

group

stringThe cache data group

Response

boolTrue if the cache ID is valid

_cleanPath

Function to strip additional / or \ in a path name

_cleanPath( path,  ds = DIRECTORY_SEPARATOR) : 
since

1.7.0

Arguments

path

stringThe path to clean

ds

stringDirectory separator (optional)

Response

stringThe cleaned path

_deleteFolder

Quickly delete a folder of files

_deleteFolder( path) : 
since

1.7.0

Arguments

path

stringThe path to the folder to delete.

Response

bool

_filesInFolder

Utility function to quickly read the files in a folder.

_filesInFolder( path,  filter = '.',  recurse = false,  fullpath = false, mixed||string|int exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], mixed||string|int excludefilter = ['^\..*', '.*~']) : mixed||string|int
since

1.7.0

Arguments

path

stringThe path of the folder to read.

filter

stringA filter for file names.

recurse

mixedTrue to recursively search into sub-folders, or an integer to specify the maximum depth.

fullpath

boolTrue to return the full path to the file.

exclude

array<string|int, mixed>Array with names of files which should not be shown in the result.

excludefilter

array<string|int, mixed>Array of folder names to exclude

Response

array<string|int, mixed>Files in the given folder.

_folders

Utility function to read the folders in a folder.

_folders( path,  filter = '.',  recurse = false,  fullpath = false, mixed||string|int exclude = ['.svn', 'CVS', '.DS_Store', '__MACOSX'], mixed||string|int excludefilter = ['^\..*']) : mixed||string|int
since

1.7.0

Arguments

path

stringThe path of the folder to read.

filter

stringA filter for folder names.

recurse

mixedTrue to recursively search into sub-folders, or an integer to specify the maximum depth.

fullpath

boolTrue to return the full path to the folders.

exclude

array<string|int, mixed>Array with names of folders which should not be shown in the result.

excludefilter

array<string|int, mixed>Array with regular expressions matching folders which should not be shown in the result.

Response

array<string|int, mixed>Folders in the given folder.

_getCacheId

Get a cache ID string from an ID/group pair

_getCacheId( id,  group) : 
inherited
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

Response

string

_getFilePath

Get a cache file path from an ID/group pair

_getFilePath( id,  group) : bool|string
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

Response

bool|stringThe path to the data object or boolean false if the cache directory does not exist

addIncludePath

Add a directory where CacheStorage should search for handlers. You may either pass a string or an array of directories.

addIncludePath(array|string path = '') : mixed||string|int
inherited static
since

1.7.0

Arguments

path

array<string|int, mixed>|stringA path to search.

Response

array<string|int, mixed>An array with directory elements

clean

Clean cache for a group given a mode.

clean( group,  mode = null) : 

group mode : cleans all cache in the group notgroup mode : cleans all cache not in the group

since

1.7.0

Arguments

group

stringThe cache data group

mode

stringThe mode for cleaning cache [group|notgroup]

Response

bool

contains

Check if the cache contains data stored by ID and group

contains( id,  group) : 
since

3.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

Response

bool

flush

Flush all existing items in storage.

flush() : 
inherited
since

3.6.3

Response

bool

gc

Garbage collect expired cache data

gc() : 
since

1.7.0

Response

bool

get

Get cached data by ID and group

get( id,  group,  checkTime = true) : 
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

checkTime

boolTrue to verify cache time expiration threshold

Response

mixedBoolean false on failure or a cached data object

getAll

Get all cached data

getAll() : 
since

1.7.0

Response

mixedBoolean false on failure or a cached data object

getInstance

Returns a cache storage handler object.

getInstance( handler = null, mixed||string|int options = []) : \Joomla\CMS\Cache\CacheStorage
inherited static
since

1.7.0

throws

UnexpectedValueException

UnsupportedCacheException

Arguments

handler

stringThe cache storage handler to instantiate

options

array<string|int, mixed>Array of handler options

Response

CacheStorage

isSupported

Test to see if the storage handler is available.

isSupported() : 
inherited static
since

3.0.0

Response

bool

lock

Lock cached item

lock( id,  group,  locktime) : 
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

locktime

intCached item max lock time

Response

mixedBoolean false if locking failed or an object containing properties lock and locklooped

remove

Remove a cached data entry by ID and group

remove( id,  group) : 
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

Response

bool

store

Store the data to cache by ID and group

store( id,  group,  data) : 
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

data

stringThe data to store in cache

Response

bool

unlock

Unlock cached item

unlock( id,  group = null) : 
since

1.7.0

Arguments

id

stringThe cache data ID

group

stringThe cache data group

Response

bool

Properties

rawname

The raw object name

inherited
since

1.7.0

Type(s)

string

_now

Time that the cache storage handler was instantiated

inherited
since

1.7.0

Type(s)

int

_lifetime

Cache lifetime

inherited
since

1.7.0

Type(s)

int

_locking

Flag if locking is enabled

inherited
since

1.7.0

Type(s)

bool

_language

Language code

inherited
since

1.7.0

Type(s)

string

_application

Application name

inherited
since

1.7.0

Type(s)

string

_hash

Object hash

inherited
since

1.7.0

Type(s)

string

_threshold

The threshold

inherited
since

4.3.0

Type(s)

int

_root

Root path

since

1.7.0

Type(s)

string

_locked_files

Locked resources

since

3.7.0

Type(s)

array<string|int, mixed>