summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-15 12:37:36 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-15 12:37:36 +0100
commitb37634a57de1f6a814687670b32472895ed49314 (patch)
tree08812523f661355a1da23de4cfac4f3e0b59a476
parentd8867f7692aae2cc5bb2ffaf00c53c9e77c61faf (diff)
parentd195584a324d0b1b2c41e50ad1e545067150aed2 (diff)
downloadnextcloud-server-b37634a57de1f6a814687670b32472895ed49314.tar.gz
nextcloud-server-b37634a57de1f6a814687670b32472895ed49314.zip
Merge pull request #21721 from owncloud/capped-memcache-indirect-set
Allow indirect set in CappedMemoryCache
-rw-r--r--lib/private/cache/cappedmemorycache.php4
-rw-r--r--tests/lib/cache/cappedmemorycache.php12
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/cache/cappedmemorycache.php b/lib/private/cache/cappedmemorycache.php
index cfaf78c51df..e3efbf76a23 100644
--- a/lib/private/cache/cappedmemorycache.php
+++ b/lib/private/cache/cappedmemorycache.php
@@ -64,8 +64,8 @@ class CappedMemoryCache implements ICache, \ArrayAccess {
return $this->hasKey($offset);
}
- public function offsetGet($offset) {
- return $this->get($offset);
+ public function &offsetGet($offset) {
+ return $this->cache[$offset];
}
public function offsetSet($offset, $value) {
diff --git a/tests/lib/cache/cappedmemorycache.php b/tests/lib/cache/cappedmemorycache.php
index 5444d928421..a8fb273b80a 100644
--- a/tests/lib/cache/cappedmemorycache.php
+++ b/tests/lib/cache/cappedmemorycache.php
@@ -64,4 +64,16 @@ class CappedMemoryCache extends \Test_Cache {
$this->assertFalse($this->instance->hasKey('2_value1'));
$this->assertFalse($this->instance->hasKey('3_value1'));
}
+
+ function testIndirectSet() {
+ $this->instance->set('array', []);
+
+ $this->instance['array'][] = 'foo';
+
+ $this->assertEquals(['foo'], $this->instance->get('array'));
+
+ $this->instance['array']['bar'] = 'qwerty';
+
+ $this->assertEquals(['foo', 'bar' => 'qwerty'], $this->instance->get('array'));
+ }
}