CachedFile
in package
Class to manage cached text-based files.
Tags
Table of Contents
Properties
- $directory : string
- $filename : string
- $cache_days_ttl : int
Methods
- __construct() : mixed
- Initialized a CachedFile object with an associated file location
- get_age() : int
- Get cache age in days (how days old is the cache file)
- get_path() : string
- Get the cached file path
- is_old() : bool
- Return TRUE if the cache is old
- load() : string
- Load the cached file as text string
- store() : mixed
- Write/Overwrite the cached file with a new text string.
Properties
$directory
public
static string
$directory
$filename
public
static string
$filename
$cache_days_ttl
protected
int
$cache_days_ttl
= 1
Methods
__construct()
Initialized a CachedFile object with an associated file location
public
__construct(string $directory, string $filename, mixed $init_content) : mixed
Parameters
- $directory : string
-
the directory containing the cached file.
- $filename : string
-
the name of the cached file.
- $init_content : mixed
-
initial content of the cached file.
Tags
get_age()
Get cache age in days (how days old is the cache file)
public
get_age() : int
Tags
Return values
int —the cache age in days.
get_path()
Get the cached file path
public
get_path() : string
Tags
Return values
string —the cached file path.
is_old()
Return TRUE if the cache is old
public
is_old() : bool
Return TRUE if the cache age in days is more than the cache TTL specified for the class.
Tags
Return values
bool —TRUE if the cache is old.
load()
Load the cached file as text string
public
load() : string
Tags
Return values
string —the cached file as text string.
store()
Write/Overwrite the cached file with a new text string.
public
store(string $content) : mixed
Parameters
- $content : string
-
the text string to cache.