TOP

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().
Source
VolatileCacheProvider.php
Implements
Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
Package
Mobi\Mtld\DA\Device\CacheProvider
Author
DeviceAtlas Limited

Constants

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.

Methods

__construct

Mobi_Mtld_DA_CacheProvider_VolatileCacheProvider $obj = new Mobi_Mtld_DA_CacheProvider_VolatileCacheProvider(

)

Construct a CacheProvider object.

Returns

void

clear

bool $obj->clear()

Clear the whole cache.

Returns

bool
true=cache cleared

delete

bool $obj->delete(string key)

Remove an item from the cache.

Arguments

    key (string)
    cache key

Returns

bool
true=cache deleted

get

mixed $obj->get(string key)

Get a stored value form cache.

Arguments

    key (string)
    cache key

Returns

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

getMaxCacheEntries

int $obj->getMaxCacheEntries()

Get the max number of allowed cache entries.

Returns

int

getNumCacheEntries

int $obj->getNumCacheEntries()

Get number of entries

Returns

int

isEnabled

bool $obj->isEnabled()

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

Returns

bool

set

bool $obj->set(string key)

Store a value in cache.

Value
mixed value value to be set to the cache key

Arguments

    key (string)
    cache key

Returns

bool
true=cache stored

setMaxCacheEntries

void $obj->setMaxCacheEntries(int $maxCacheEntries)

Set the max number of allowed entries in cache.

Arguments

    $maxCacheEntries (int)

Returns

void