aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2013-04-13 14:35:24 -0400
committercash <cash.costello@gmail.com>2013-04-13 14:35:24 -0400
commitfc9a1e985b0b20c74a913f22ec9ea7e0c16848a7 (patch)
tree8738a742232753ac0bfbbb081ec43a1182cdc4ce /engine
parent53b226d0e3d81c0cf45b2b39b506275a7a149ebe (diff)
downloadelgg-fc9a1e985b0b20c74a913f22ec9ea7e0c16848a7.tar.gz
elgg-fc9a1e985b0b20c74a913f22ec9ea7e0c16848a7.tar.bz2
updated lru cache so easier to integrate
Diffstat (limited to 'engine')
-rw-r--r--engine/classes/ElggLRUCache.php55
1 files changed, 52 insertions, 3 deletions
diff --git a/engine/classes/ElggLRUCache.php b/engine/classes/ElggLRUCache.php
index add78ecb4..90e63bb61 100644
--- a/engine/classes/ElggLRUCache.php
+++ b/engine/classes/ElggLRUCache.php
@@ -13,7 +13,7 @@
* @package Elgg.Core
* @subpackage Cache
*/
-class ElggLRUCache {
+class ElggLRUCache implements ArrayAccess {
/** @var int */
protected $maximumSize;
@@ -54,13 +54,13 @@ class ElggLRUCache {
}
/**
- * Put something in the cache
+ * Add something to the cache
*
* @param int|string $key The key. Strings that are ints are cast to ints.
* @param mixed $value The value to cache
* @return void
*/
- public function put($key, $value) {
+ public function set($key, $value) {
if (isset($this->data[$key])) {
$this->data[$key] = $value;
$this->recordAccess($key);
@@ -129,4 +129,53 @@ class ElggLRUCache {
unset($this->data[$key]);
$this->data[$key] = $value;
}
+
+ /**
+ * Assigns a value for the specified key
+ *
+ * @see ArrayAccess::offsetSet()
+ *
+ * @param int|string $key The key to assign the value to.
+ * @param mixed $value The value to set.
+ * @return void
+ */
+ function offsetSet($key, $value) {
+ $this->set($key, $value);
+ }
+
+ /**
+ * Get the value for specified key
+ *
+ * @see ArrayAccess::offsetGet()
+ *
+ * @param int|string $key The key to retrieve.
+ * @return mixed
+ */
+ function offsetGet($key) {
+ return $this->get($key);
+ }
+
+ /**
+ * Unsets a key.
+ *
+ * @see ArrayAccess::offsetUnset()
+ *
+ * @param int|string $key The key to unset.
+ * @return void
+ */
+ function offsetUnset($key) {
+ $this->remove($key);
+ }
+
+ /**
+ * Does key exist?
+ *
+ * @see ArrayAccess::offsetExists()
+ *
+ * @param int|string $key A key to check for.
+ * @return boolean
+ */
+ function offsetExists($key) {
+ return $this->containsKey($key);
+ }
}