Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/123' into develop, Forward port #123
Browse files Browse the repository at this point in the history
Conflicts:
	doc/book/storage/adapter.md
	src/Storage/Adapter/AbstractZendServer.php
	src/Storage/Capabilities.php
	test/Storage/Adapter/CommonAdapterTest.php
  • Loading branch information
marc-mabe committed Dec 16, 2016
2 parents e4803c0 + d653993 commit 064788a
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 37 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ All notable changes to this project will be documented in this file, in reverse

### Deprecated

- Nothing.
- [#123](https://github.com/zendframework/zend-cache/pull/123)
Deprecate capability "expiredRead".
It's basically providing the same information as staticTtl but from a wrong PoV

### Removed

Expand Down
15 changes: 3 additions & 12 deletions doc/book/storage/adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | value of `apc.use_request_time` from `php.ini`
`expiredRead` | `false`
`lockOnExpire` | 0
`maxKeyLength` | 5182
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -632,7 +631,6 @@ Capability | Value
`staticTtl` | `false`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `true`
`lockOnExpire` | 0
`maxKeyLength` | 251
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -678,7 +676,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`lockOnExpire` | 0
`maxKeyLength` | 255
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -712,7 +709,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`lockOnExpire` | 0
`maxKeyLength` | 255
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -763,7 +759,6 @@ Capability | Value
`staticTtl` | `false`
`ttlPrecision` | 0.05
`useRequestTime` | `false`
`expiredRead` | `true`
`lockOnExpire` | 0
`maxKeyLength` | 0
`namespaceIsPrefix` | `false`
Expand Down Expand Up @@ -801,15 +796,15 @@ This adapter implements the following interfaces:

### Capabilities

Capability Value
`supportedDatatypes` | `null`, `boolean`, `integer`, `double`, `string`, `array`
Capability | Value
---------- | -----
`supportedDatatypes` | `string`, `null`, `boolean`, `integer`, `double`, `array`
`supportedMetadata` | _id
`minTtl` | 0
`maxTtl` | 0
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`lockOnExpire` | 0
`maxKeyLength` | 255
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -855,7 +850,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `apc.use_request_time` `php.ini` value.
`expiredRead` | `false`
`lockOnExpire` | 0
`namespaceIsPrefix` | `true`
`namespaceSeparator` | Option value of `namespace_separator`
Expand Down Expand Up @@ -892,7 +886,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `true`
`expiredRead` | `false`
`lockOnExpire` | 0
`maxKeyLength` | 5182
`namespaceIsPrefix` | `true`
Expand Down Expand Up @@ -932,7 +925,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`lockOnExpire` | if 'zend_datacache.lock_on_expire' is enabled 120 else 0
`namespaceIsPrefix` | `true`
`namespaceSeparator` | `::`
Expand Down Expand Up @@ -961,7 +953,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`lockOnExpire` | if 'zend_datacache.lock_on_expire' is enabled 120 else 0
`namespaceIsPrefix` | `true`
`namespaceSeparator` | `::`
Expand Down
4 changes: 4 additions & 0 deletions doc/book/storage/capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class Capabilities
* Get if expired items are readable
*
* @return bool
* @deprecated This capability has been deprecated and will be removed in the future.
* Please use getStaticTtl() instead
*/
public function getExpiredRead();

Expand All @@ -179,6 +181,8 @@ class Capabilities
* @param stdClass $marker
* @param bool $flag
* @return Capabilities Fluent interface
* @deprecated This capability has been deprecated and will be removed in the future.
* Please use setStaticTtl() instead
*/
public function setExpiredRead(stdClass $marker, $flag);

Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/AbstractZendServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'lockOnExpire' => ini_get('zend_datacache.lock_on_expire') ? 120 : 0,
'maxKeyLength' => 0,
'namespaceIsPrefix' => true,
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Apc.php
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => (bool) ini_get('apc.use_request_time'),
'expiredRead' => false,
'maxKeyLength' => 5182,
'namespaceIsPrefix' => true,
'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => (bool) ini_get('apc.use_request_time'),
'expiredRead' => false,
'maxKeyLength' => 5182,
'namespaceIsPrefix' => true,
'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,6 @@ protected function internalGetCapabilities()
'maxTtl' => 0,
'staticTtl' => false,
'ttlPrecision' => 1,
'expiredRead' => true,
'maxKeyLength' => 251, // 255 - strlen(.dat | .tag)
'namespaceIsPrefix' => true,
'namespaceSeparator' => $options->getNamespaceSeparator(),
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Memcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'maxKeyLength' => 255,
'namespaceIsPrefix' => true,
]
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Memcached.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'maxKeyLength' => 255,
'namespaceIsPrefix' => true,
]
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ protected function internalGetCapabilities()
'maxTtl' => PHP_INT_MAX,
'staticTtl' => false,
'ttlPrecision' => 0.05,
'expiredRead' => true,
'maxKeyLength' => 0,
'namespaceIsPrefix' => false,
'namespaceSeparator' => '',
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/Redis.php
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'maxKeyLength' => 255,
'namespaceIsPrefix' => true,
]
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/WinCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'namespaceIsPrefix' => true,
'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
]
Expand Down
1 change: 0 additions & 1 deletion src/Storage/Adapter/XCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => true,
'expiredRead' => false,
'maxKeyLength' => 5182,
'namespaceIsPrefix' => true,
'namespaceSeparator' => $this->getOptions()->getNamespaceSeparator(),
Expand Down
26 changes: 14 additions & 12 deletions src/Storage/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ class Capabilities
*/
protected $baseCapabilities;

/**
* Expire read
*
* If it's NULL the capability isn't set and the getter
* returns the base capability or the default value.
*
* @var null|bool
*/
protected $expiredRead;

/**
* "lock-on-expire" support in seconds.
*
Expand Down Expand Up @@ -417,10 +407,16 @@ public function setUseRequestTime(stdClass $marker, $flag)
* Get if expired items are readable
*
* @return bool
* @deprecated This capability has been deprecated and will be removed in the future.
* Please use getStaticTtl() instead
*/
public function getExpiredRead()
{
return $this->getCapability('expiredRead', false);
trigger_error(
'This capability has been deprecated and will be removed in the future. Please use static_ttl instead',
E_USER_DEPRECATED
);
return ! $this->getCapability('staticTtl', true);
}

/**
Expand All @@ -429,10 +425,16 @@ public function getExpiredRead()
* @param stdClass $marker
* @param bool $flag
* @return Capabilities Fluent interface
* @deprecated This capability has been deprecated and will be removed in the future.
* Please use setStaticTtl() instead
*/
public function setExpiredRead(stdClass $marker, $flag)
{
return $this->setCapability($marker, 'expiredRead', (bool) $flag);
trigger_error(
'This capability has been deprecated and will be removed in the future. Please use static_ttl instead',
E_USER_DEPRECATED
);
return $this->setCapability($marker, 'staticTtl', (bool) $flag);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions test/Storage/Adapter/CommonAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ public function testTtlCapabilities()
$this->assertInternalType('numeric', $capabilities->getTtlPrecision());
$this->assertGreaterThan(0, $capabilities->getTtlPrecision());

$this->assertInternalType('bool', $capabilities->getExpiredRead());
$this->assertInternalType('int', $capabilities->getLockOnExpire());
}

Expand Down Expand Up @@ -647,7 +646,7 @@ public function testSetAndGetExpiredItems()
$rs = $this->_storage->getItems(array_keys($items));
ksort($rs); // make comparable

if ($capabilities->getExpiredRead()) {
if (! $capabilities->getStaticTtl()) {
// if item expiration will be done on read there is no difference
// between the previos set items in TTL.
// -> all items will be expired
Expand Down

0 comments on commit 064788a

Please sign in to comment.