\Mobi_Mtld_DA_CacheProvider_VolatileCacheProvider

Volatile cache can be used by the DeviceApi class to cache the detected properties. Using cache improves the performance by not doing unnecessary lookups in the data files.

It is based on an associative array where the key is CRC3 hashed and the value can be any data type.

In a stateless web application, there is no point to use this cache provider. It is mainly meant to client environments where repeated User-Agents are checked (e.g. processing a User-Agent list) and the cache provider can be kept in memory across different calls to getProperties().

Summary

Methods
Properties
Constants
__construct()
get()
set()
delete()
clear()
setMaxCacheEntries()
getMaxCacheEntries()
getNumCacheEntries()
isEnabled()
No public properties found
DEFAULT_MAX_CACHE_ENTRIES
No protected methods found
No protected properties found
N/A
No private methods found
$volatileCache
$maxCacheEntries
$cachedValuesCount
N/A

Constants

DEFAULT_MAX_CACHE_ENTRIES

DEFAULT_MAX_CACHE_ENTRIES = 4096

The default value to set the maximum number of cache entries we can save. It must be integer, which means the maximum number of allowed entries is 2147483647. If value is 0, then cache is disabled.

Properties

$volatileCache

$volatileCache : 

Type

$maxCacheEntries

$maxCacheEntries : 

Type

$cachedValuesCount

$cachedValuesCount : 

Type

Methods

__construct()

__construct() 

Construct a CacheProvider object.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

get()

get(  $key) : mixed

Get a stored value form cache.

Parameters

$key
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

mixed —

the cached value or null if the key does not exist in cache

set()

set(  $key,   $value) : boolean

Store a value in cache.

Parameters

$key
$value
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean —

true=cache stored

delete()

delete(  $key) : boolean

Remove an item from the cache.

Parameters

$key
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean —

true=cache deleted

clear()

clear() : boolean

Clear the whole cache.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean —

true=cache cleared

setMaxCacheEntries()

setMaxCacheEntries(integer  $maxCacheEntries) 

Set the max number of allowed entries in cache.

Parameters

integer $maxCacheEntries
Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

getMaxCacheEntries()

getMaxCacheEntries() : integer

Get the max number of allowed cache entries.

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

integer

getNumCacheEntries()

getNumCacheEntries() : integer

Get number of entries

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

integer

isEnabled()

isEnabled() : boolean

Return whether cache is enabled (more than zero allowed cache entries).

Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275 Warning: count(): Parameter must be an array or an object that implements Countable in /opt/phpdoc/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275

Returns

boolean