FileCacheStorage
in package
File cache storage
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- append() : void
- Append content to cache file
- delete() : void
- Delete cache file
- isValid() : bool
- Is cache file still valid
- read() : string|null
- Get cache content
- write() : void
- Write content into cache file
- isWritable() : bool
- Can be cache file edited
- keepCache() : bool
- Should reset cache
- getLock() : bool
- Lock file
- getResource() : resource
- Try to get a file pointer resource
Properties
$file
private
string
$file
Cache file location
$pause
private
int
$pause
Keep cache longer than it should e.g. rebuild cache max once per minute
$reset
private
string|null
$reset
Force reset every nth minutes/hour/day/month (i/h/d/m) (no inner conversion !!!)
Methods
__construct()
public
__construct(string $file[, string|null $reset = null ][, int $pause = 0 ]) : mixed
Parameters
- $file : string
- $reset : string|null = null
- $pause : int = 0
Tags
append()
Append content to cache file
public
append(string $content) : void
Parameters
- $content : string
delete()
Delete cache file
public
delete() : void
isValid()
Is cache file still valid
public
isValid(DateTime $last) : bool
Parameters
- $last : DateTime
Return values
boolread()
Get cache content
public
read() : string|null
Return values
string|nullwrite()
Write content into cache file
public
write(string $content) : void
Parameters
- $content : string
isWritable()
Can be cache file edited
protected
isWritable([bool $retry = true ]) : bool
Parameters
- $retry : bool = true
Return values
boolkeepCache()
Should reset cache
protected
keepCache(DateTime $cached) : bool
Parameters
- $cached : DateTime
Tags
Return values
boolgetLock()
Lock file
private
getLock(resource $fp, int $mode, int $sleep) : bool
Parameters
- $fp : resource
- $mode : int
- $sleep : int
Return values
boolgetResource()
Try to get a file pointer resource
private
getResource(string $file, string $mode[, int $attempts = 0 ]) : resource
Parameters
- $file : string
- $mode : string
- $attempts : int = 0