Documentation

Config
in package

DeviceApi Configurations. To change the default configs of the DeviceAtlas DeviceApi create an instance of this class, set your preferred configs and pass the instance to the constructor of a DeviceApi. Note that you may change the configs even after the Config instance has been passed to the DeviceApi.

Tags
author

DeviceAtlas Limited

copyright

Copyright (c) DeviceAtlas Limited 2023. All Rights Reserved.

Table of Contents

Constants

DEFAULT_COOKIE_NAME  = "DAPROPS"
The default cookie name that the client side properties would be set to.
DEFAULT_MAX_CACHE_ENTRIES  = 4096
The default config value for result (Properties object) caching. Depending on the frequency and distance factor of your user-agents or headers passed to the API for detection the result cache may increase performance by preventing repeated lookups.

Properties

$cacheProvider  : mixed
$cookieName  : mixed
$ignoreDataFileChanges  : mixed
$maxCacheEntries  : mixed
$optimizerTempDir  : mixed
$useTreeOptimizer  : mixed

Methods

getCacheProvider()  : Cache
Get the cache provider instance being used by the API to cache the lookup results.
getCookieName()  : string
Get the cookie name that the client side properties would be set to.
getIgnoreDataFileChanges()  : mixed
Get if the data file optimizer should do data file update automatic checking.
getMaxCacheEntries()  : int
Get the max number of results to be cached.
getOptimizerTempDir()  : string
Get the temp directory path in which the optimizer puts the cached files.
getUseTreeOptimizer()  : bool
To get data optimization status. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.
setCacheProvider()  : mixed
Set a cache provider to the API to cache the lookup results. This will dramatically increase the lookup performance in most situations. It is highly recommend to use this config when detecting devices in real-time using DeviceAtlasWeb.
setCookieName()  : mixed
To change the cookie name that the client side properties would be set to.
setIgnoreDataFileChanges()  : mixed
When data file optimizer is set to true using the "setUseTreeOptimizer()" config, the API will try to use a batch of optimized cached files instead of the original data file, the API will do several checks to pick between the cached data file or the passed data file. While this makes the API automatically sense and update the cached files.
setMaxCacheEntries()  : mixed
Set the max number of results to be cached. Depending on the frequency and distance factor of your User-Agents or headers passed to the API for detection, increasing the result cache may increase performance by preventing repeated lookups. For a large set of inputs (i.e. an almost unique set of user-agents) set to lower numbers or 0 to disable.
setOptimizerTempDir()  : mixed
When optimizer is turned on, the cached files will be put inside the system directory by default, you can change the default optimizer temp/cache directory with this method.
setUseTreeOptimizer()  : mixed
To optimize data. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.

Constants

The default cookie name that the client side properties would be set to.

public mixed DEFAULT_COOKIE_NAME = "DAPROPS"

When using getProperties() in a web application, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas client side component (JS lib) to your web-site pages.

DEFAULT_MAX_CACHE_ENTRIES

The default config value for result (Properties object) caching. Depending on the frequency and distance factor of your user-agents or headers passed to the API for detection the result cache may increase performance by preventing repeated lookups.

public mixed DEFAULT_MAX_CACHE_ENTRIES = 4096

Properties

$cacheProvider

private mixed $cacheProvider

$cookieName

private mixed $cookieName = self::DEFAULT_COOKIE_NAME

$ignoreDataFileChanges

private mixed $ignoreDataFileChanges = false

$maxCacheEntries

private mixed $maxCacheEntries = self::DEFAULT_MAX_CACHE_ENTRIES

$optimizerTempDir

private mixed $optimizerTempDir

$useTreeOptimizer

private mixed $useTreeOptimizer = false

Methods

getCacheProvider()

Get the cache provider instance being used by the API to cache the lookup results.

public getCacheProvider() : Cache

null is returned when a cache provider is not used.

Return values
Cache

a cache provider instance or null

getCookieName()

Get the cookie name that the client side properties would be set to.

public getCookieName() : string

When using getProperties() in a web application, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas client side component (JS lib) to your web-site pages.

When the user-agent or HTTP headers are set manually to getProperties() the client side properties (probably the value set to the cookie) can be manually passed to this methods as the second argument, note that this config is only used for getProperties(REQUEST-OBJECT).

Return values
string

The cookie name which the client side properties are set to

getIgnoreDataFileChanges()

Get if the data file optimizer should do data file update automatic checking.

public getIgnoreDataFileChanges() : mixed

getMaxCacheEntries()

Get the max number of results to be cached.

public getMaxCacheEntries() : int
Return values
int

getOptimizerTempDir()

Get the temp directory path in which the optimizer puts the cached files.

public getOptimizerTempDir() : string
Return values
string

path to the optimizer temp directory

getUseTreeOptimizer()

To get data optimization status. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.

public getUseTreeOptimizer() : bool
Return values
bool

true=data optimizer is on

setCacheProvider()

Set a cache provider to the API to cache the lookup results. This will dramatically increase the lookup performance in most situations. It is highly recommend to use this config when detecting devices in real-time using DeviceAtlasWeb.

public setCacheProvider(Cache $cacheProvider) : mixed
Parameters
$cacheProvider : Cache

a cache provider instance

setCookieName()

To change the cookie name that the client side properties would be set to.

public setCookieName(string $cookieName) : mixed

When using getProperties() in a web application, the detection would automatically use the contents of this cookie if it exists. If you want the client side properties to be used add the DeviceAtlas client side component (JS lib) to your web-site pages.

When the user-agent or HTTP headers are set manually to getProperties() the client side properties (probably the value set to the cookie) can be manually passed to this methods as the second argument, note that this config is only used for getProperties(REQUEST-OBJECT). If you set the cookie-name to null then the client-side properties cookie will be ignored.

Parameters
$cookieName : string

The cookie name which the client side properties are set to. Set to null to turn off using client-side properties

setIgnoreDataFileChanges()

When data file optimizer is set to true using the "setUseTreeOptimizer()" config, the API will try to use a batch of optimized cached files instead of the original data file, the API will do several checks to pick between the cached data file or the passed data file. While this makes the API automatically sense and update the cached files.

public setIgnoreDataFileChanges(bool $ignoreDataFileChanges) : mixed
Parameters
$ignoreDataFileChanges : bool

setMaxCacheEntries()

Set the max number of results to be cached. Depending on the frequency and distance factor of your User-Agents or headers passed to the API for detection, increasing the result cache may increase performance by preventing repeated lookups. For a large set of inputs (i.e. an almost unique set of user-agents) set to lower numbers or 0 to disable.

public setMaxCacheEntries( $maxCacheEntries) : mixed
Parameters
$maxCacheEntries :

setOptimizerTempDir()

When optimizer is turned on, the cached files will be put inside the system directory by default, you can change the default optimizer temp/cache directory with this method.

public setOptimizerTempDir(string $optimizerTempDir) : mixed
Parameters
$optimizerTempDir : string

path to temp directory

setUseTreeOptimizer()

To optimize data. Optimizing the data file will dramatically reduce the memory foot print and data file loading speed. It is highly recommend to turn this config on when detecting devices in real-time using DeviceAtlasWeb.<br/> When this config is on, the API will automatically divide the data file into smaller pieces and cache them on the disk, the cached data will be used for lookups afterwards. The API detects data file updates and will update the cache.

public setUseTreeOptimizer(bool $useTreeOptimizer) : mixed
Parameters
$useTreeOptimizer : bool

true=turn on data optimizer (by default this config is off for DeviceApi but on for DeviceApiWeb)


        
On this page

Search results