APC cache implementation

See the implementation in \OSS_SNMP\Cache\Basic for proper examples and documentation.
copyright Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland
author Barry O'Donovan

 Methods

Cache constructor.

__construct(int $ttl = 300, string $prefix = 'OSS_SNMP_') : \OSS_SNMP\Cache\Basic
For basic cache, takes no parameters.

Parameters

$ttl

int

Set the default ttl

$prefix

string

Set the default prefix for caching variable names

Returns

\OSS_SNMP\Cache\BasicAn instance of the cache ($this) for fluent interfaces

Clear a named value from the cache

clear(string $var) 

Parameters

$var

string

The name of the value to clear

Clear all values from the cache

clearAll() 

Load a named value from the cache (or null if not present)

load(string $var) : mixed | null

Parameters

$var

string

The name of the value to load

Returns

mixednullThe value from the cache or null

Save a named value to the cache

save(string $var, mixed $val, int $ttl = null) : mixed

Parameters

$var

string

The name of the value to save

$val

mixed

The value to save

$ttl

int

The time to live of the variable if you want to override the default

Returns

mixedThe value (as passed)

clear()

clear($varName) 

Parameters

$varName

clearAll()

clearAll() 

load()

load($varName) 

Parameters

$varName

save()

save($varName, $varValue) 

Parameters

$varName

$varValue

 Properties

 

Prefix to use for caching items

$_prefix : string

Default

'OSS_SNMP_'
 

Default time to live for cache variables in seconds

$_ttl : int

Default

300