Documentation

CachedJson extends CachedFile
in package

Class to manage cached JSON-based files.

Tags
author

Davide Lanza davide.lanza@eikonproject.org

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()  : mixed
Load the cached JSON file as JSON-like object
store()  : mixed
Write/Overwrite the cached file with a new JSON.

Properties

$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
author

Davide Lanza davide.lanza@eikonproject.org

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
author

Davide Lanza davide.lanza@eikonproject.org

Return values
bool

TRUE if the cache is old.

load()

Load the cached JSON file as JSON-like object

public load() : mixed
Tags
author

Davide Lanza davide.lanza@eikonproject.org

Return values
mixed

the cached JSON file as JSON-like object.

store()

Write/Overwrite the cached file with a new JSON.

public store(mixed $content) : mixed
Parameters
$content : mixed

the JSON-like object to cache.

Tags
author

Davide Lanza davide.lanza@eikonproject.org


        
On this page

Search results