\HD3Cache

Summary

Methods
Properties
Constants
getCacheDir()
setDirectory()
read()
write()
readStore()
writeStore()
writeFile()
readSpecs()
__encode()
__decode()
$prefix
$dirpath
$dirname
$duration
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$prefix

$prefix : 

Type

$dirpath

$dirpath : 

Type

$dirname

$dirname : 

Type

$duration

$duration : 

Type

Methods

getCacheDir()

getCacheDir() 

setDirectory()

setDirectory(  $dir) 

Parameters

$dir

read()

read(string  $key) : \$data

Read the key from memory cache

Parameters

string $key

Returns

\$data —

if found, false otherwise

write()

write(string  $key, array  $data) : boolean

Write data to memory cache accessed by $key

Parameters

string $key
array $data

Returns

boolean —

true on success, false otherwise

readStore()

readStore(\sting  $key) : boolean

Trys memory and filesystem to find data.

If not found in memory and found on disk then save to memory for faster access later.

Parameters

\sting $key

Key to search for

Returns

boolean —

true on success, false otherwise

writeStore()

writeStore(string  $key, array  $data) : boolean

Persists data to disk (does not save in memory, readStore will load it onto memory if required)

Parameters

string $key

The search key

array $data

Data to persist (will be persisted in json format)

Returns

boolean —

true on success, false otherwise

writeFile()

writeFile(string  $srcAbsName, string  $destName) : boolean

Writes a file into the disk store

Note : File data must be a json string if you ever intend to read it back later with readStore()

Parameters

string $srcAbsName

The fully qualified path and file name eg /tmp/sjjhas778hsjhh

string $destName

The key name inside the cache eg Device_19.json

Returns

boolean —

true on success, false otherwise

readSpecs()

readSpecs() : \$data

Used by the local functions. Reads the Device specs into one large array.

Returns

\$data

__encode()

__encode(\json  $data) : \$data

Encodes php assoc array to json string

Parameters

\json $data

Returns

\$data

__decode()

__decode(\json  $jsonstr) : \$data

Decode turns json string into php assoc array

Parameters

\json $jsonstr

Returns

\$data