DeviceAtlas Device API
 All Classes Namespaces Functions Variables
Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Mobi_Mtld_DA_TreeOptimizer Class Reference

Static Public Member Functions

static getTreeFromFile ($path_to_json, $user_agent, $cache_dir=null)
static getShardId ($user_agent)
static populateCache ($path_to_json, $cache_dir=null, $force=false)
static clearCache ($cache_dir=null)

Public Attributes

const SHARD_PREFIX = 'json.'

Static Public Attributes

static $use_subtree_optimization = true
static $subtree_optimization

Detailed Description

This class optimizes loading of the main JSON tree.

Optimization 1: we split main JSON tree based on the first character in the User-Agent string. It creates several smaller json files which are saved in the system temp directory.

There might be more optimizations coming in the future releases

Author
dotMobi

Member Function Documentation

static Mobi_Mtld_DA_TreeOptimizer::getTreeFromFile (   $path_to_json,
  $user_agent,
  $cache_dir = null 
)
static

Returns optimized tree from a JSON file Use an absolute path name to be sure of success if the current working directory is not clear.

Parameters
string$path_to_jsonThe location of the file to read in.
string$user_agentstring from the device's User-Agent header
string$cache_diruses sys_get_temp_dir() by default
Returns
array tree

Member Data Documentation

Mobi_Mtld_DA_TreeOptimizer::$subtree_optimization
static
Initial value:
array (
77 => array(
'iphone' => 'Mozilla/5.0 (i',
'linux' => 'Mozilla/5.0 (Linux',
)
)

Do NOT add any new paths to the list unless you are 110% aware how the subtree optimization works!

Mobi_Mtld_DA_TreeOptimizer::$use_subtree_optimization = true
static

When changing from true to false and vice versa be sure you clear your Mobi_Mtld_DA_TreeOptimizer cache directory.

Linux: /tmp/Mobi_Mtld_DA_TreeOptimizer


The documentation for this class was generated from the following file: