镜像来自
https://github.com/nextcloud/server.git
synced 2024-07-30 08:15:57 +02:00
Allow indirect set in CappedMemoryCache
This commit is contained in:
父節點
8f89e3520d
當前提交
d195584a32
4
lib/private/cache/cappedmemorycache.php
vendored
4
lib/private/cache/cappedmemorycache.php
vendored
@ -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) {
|
||||
|
12
tests/lib/cache/cappedmemorycache.php
vendored
12
tests/lib/cache/cappedmemorycache.php
vendored
@ -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'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user