Skip to content

Commit

Permalink
refs matomo-org#5290 - use doctrine-cache for caching
Browse files Browse the repository at this point in the history
  • Loading branch information
sgiehl committed Dec 1, 2014
1 parent 4148cb8 commit b562c85
Show file tree
Hide file tree
Showing 14 changed files with 144 additions and 420 deletions.
125 changes: 0 additions & 125 deletions Cache/CacheFile.php

This file was deleted.

38 changes: 0 additions & 38 deletions Cache/CacheInterface.php

This file was deleted.

50 changes: 0 additions & 50 deletions Cache/CacheMemcache.php

This file was deleted.

47 changes: 0 additions & 47 deletions Cache/CacheStatic.php

This file was deleted.

78 changes: 78 additions & 0 deletions Cache/StaticCache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Device Detector - The Universal Device Detection library for parsing User Agents
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/lgpl.html LGPL v3 or later
*/
namespace DeviceDetector\Cache;

use Doctrine\Common\Cache\CacheProvider;

/**
* Class StaticCache
*
* Simple Cache that caches in a static property
* (Speeds up multiple detections in one request)
*
* @package DeviceDetector\Cache
*/
class StaticCache extends CacheProvider
{
/**
* Holds the static cache data
* @var array
*/
static protected $staticCache = array();

/**
* {@inheritdoc}
*/
protected function doFetch($id)
{
return $this->doContains($id) ? self::$staticCache[$id] : false;
}

/**
* {@inheritdoc}
*/
protected function doContains($id)
{
return isset(self::$staticCache[$id]) || array_key_exists($id, self::$staticCache);
}

/**
* {@inheritdoc}
*/
protected function doSave($id, $data, $lifeTime = 0)
{
self::$staticCache[$id] = $data;
return true;
}

/**
* {@inheritdoc}
*/
protected function doDelete($id)
{
unset(self::$staticCache[$id]);
return true;
}

/**
* {@inheritdoc}
*/
protected function doGetStats()
{
return null;
}

/**
* {@inheritdoc}
*/
protected function doFlush()
{
self::$staticCache = array();
return true;
}
}
Loading

0 comments on commit b562c85

Please sign in to comment.