implementing key/value store of Persistance in Database storage

This commit is contained in:
El RIDO 2021-06-09 07:47:40 +02:00
parent 7901ec74a7
commit a203e6322b
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
8 changed files with 86 additions and 65 deletions

View file

@ -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.