Documentation

Mobi_Mtld_DA_CacheProvider_VolatileCacheProvider implements Mobi_Mtld_DA_CacheProvider_CacheProviderInterface

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().

Tags
author

DeviceAtlas Limited

copyright

Copyright (c) DeviceAtlas Limited 2021. All Rights Reserved. https://deviceatlas.com

Interfaces, Classes and Traits

Mobi_Mtld_DA_CacheProvider_CacheProviderInterface
A cache provider such as APC or Memcache may be used by the DeviceApi and DeviceApiWeb to cache the detected properties. Using cache improves the performance by not doing unnecessary lookups in the data files. A valid cache provider must implement this interface to be usable by the APIs.

Table of Contents

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.
$cachedValuesCount  : mixed
$maxCacheEntries  : mixed
$volatileCache  : mixed
__construct()  : mixed
Construct a CacheProvider object.
clear()  : bool
Clear the whole cache.
delete()  : bool
Remove an item from the cache.
get()  : mixed
Get a stored value form cache.
getMaxCacheEntries()  : int
Get the max number of allowed cache entries.
getNumCacheEntries()  : int
Get number of entries
isEnabled()  : bool
Return whether cache is enabled (more than zero allowed cache entries).
set()  : bool
Store a value in cache.
setMaxCacheEntries()  : mixed
Set the max number of allowed entries in cache.

Constants

DEFAULT_MAX_CACHE_ENTRIES

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.

public mixed DEFAULT_MAX_CACHE_ENTRIES = 4096

Properties

Methods

__construct()

Construct a CacheProvider object.

public __construct() : mixed
Return values
mixed

clear()

Clear the whole cache.

public clear() : bool
Return values
bool

true=cache cleared

delete()

Remove an item from the cache.

public delete(mixed $key) : bool
Parameters
$key : mixed
Return values
bool

true=cache deleted

get()

Get a stored value form cache.

public get(mixed $key) : mixed
Parameters
$key : mixed
Return values
mixed

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

getMaxCacheEntries()

Get the max number of allowed cache entries.

public getMaxCacheEntries() : int
Return values
int

getNumCacheEntries()

Get number of entries

public getNumCacheEntries() : int
Return values
int

isEnabled()

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

public isEnabled() : bool
Return values
bool

set()

Store a value in cache.

public set(mixed $key, mixed $value) : bool
Parameters
$key : mixed
$value : mixed
Tags
value

mixed value value to be set to the cache key

Return values
bool

true=cache stored

setMaxCacheEntries()

Set the max number of allowed entries in cache.

public setMaxCacheEntries(int $maxCacheEntries) : mixed
Parameters
$maxCacheEntries : int
Return values
mixed

Search results