implementing key/value store of Persistance in Database storage
This commit is contained in:
@@ -28,6 +28,15 @@ abstract class AbstractData
|
||||
*/
|
||||
protected static $_instance = null;
|
||||
|
||||
/**
|
||||
* cache for the traffic limiter
|
||||
*
|
||||
* @access private
|
||||
* @static
|
||||
* @var array
|
||||
*/
|
||||
protected static $_traffic_limiter_cache = array();
|
||||
|
||||
/**
|
||||
* Enforce singleton, disable constructor
|
||||
*
|
||||
@@ -138,7 +147,16 @@ abstract class AbstractData
|
||||
* @param int $time
|
||||
* @return void
|
||||
*/
|
||||
abstract public function purgeValues($namespace, $time);
|
||||
public function purgeValues($namespace, $time)
|
||||
{
|
||||
if ($namespace === 'traffic_limiter') {
|
||||
foreach (self::$_traffic_limiter_cache as $key => $last_access) {
|
||||
if ($last_access <= $time) {
|
||||
unset(self::$_traffic_limiter_cache[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a value.
|
||||
|
||||
Reference in New Issue
Block a user