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', Close #123
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-mabe committed Dec 16, 2016
2 parents 898c6f4 + d653993 commit 982a38c
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 48 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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
32 changes: 11 additions & 21 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`
`maxKeyLength` | 5182
`namespaceIsPrefix` | `true`
`namespaceSeparator` | Option value of `namespace_separator`
Expand Down Expand Up @@ -631,7 +630,6 @@ Capability | Value
`staticTtl` | `false`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `true`
`maxKeyLength` | 251
`namespaceIsPrefix` | `true`
`namespaceSeparator` | Option value of `namespace_separator`
Expand Down Expand Up @@ -676,7 +674,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`maxKeyLength` | 255
`namespaceIsPrefix` | `true`
`namespaceSeparator` | none
Expand Down Expand Up @@ -709,7 +706,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`maxKeyLength` | 255
`namespaceIsPrefix` | `true`
`namespaceSeparator` | none
Expand Down Expand Up @@ -759,7 +755,6 @@ Capability | Value
`staticTtl` | `false`
`ttlPrecision` | 0.05
`useRequestTime` | `false`
`expiredRead` | `true`
`maxKeyLength` | 0
`namespaceIsPrefix` | `false`

Expand Down Expand Up @@ -796,18 +791,17 @@ This adapter implements the following interfaces:

### Capabilities

Capability Value
supportedDatatypes null, boolean, integer, double, string, array
supportedMetadata _id
minTtl 0
maxTtl 0
staticTtl true
ttlPrecision 1
useRequestTime false
expiredRead false
maxKeyLength 255
namespaceIsPrefix true
namespaceSeparator <Option value of namespace_separator>
Capability | Value
---------- | -----
`supportedDatatypes` | `string`, `null`, `boolean`, `integer`, `double`, `array`
`supportedMetadata` | _id
`minTtl` | 0
`maxTtl` | 0
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`maxKeyLength` | 255
`namespaceIsPrefix` | <Option value of namespace_separator>

### Adapter specific options

Expand Down Expand Up @@ -849,7 +843,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `apc.use_request_time` `php.ini` value.
`expiredRead` | `false`
`namespaceIsPrefix` | `true`
`namespaceSeparator` | Option value of `namespace_separator`

Expand Down Expand Up @@ -885,7 +878,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `true`
`expiredRead` | `false`
`maxKeyLength` | 5182
`namespaceIsPrefix` | `true`
`namespaceSeparator` | Option value of `namespace_separator`
Expand Down Expand Up @@ -924,7 +916,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`namespaceIsPrefix` | `true`
`namespaceSeparator` | `::`

Expand Down Expand Up @@ -952,7 +943,6 @@ Capability | Value
`staticTtl` | `true`
`ttlPrecision` | 1
`useRequestTime` | `false`
`expiredRead` | `false`
`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 @@ -221,7 +221,6 @@ protected function internalGetCapabilities()
'staticTtl' => true,
'ttlPrecision' => 1,
'useRequestTime' => false,
'expiredRead' => false,
'maxKeyLength' => 0,
'namespaceIsPrefix' => true,
'namespaceSeparator' => self::NAMESPACE_SEPARATOR,
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;

/**
* Max. key length
*
Expand Down Expand Up @@ -403,10 +393,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 @@ -415,10 +411,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
6 changes: 2 additions & 4 deletions test/Storage/Adapter/CommonAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,6 @@ public function testTtlCapabilities()

$this->assertInternalType('numeric', $capabilities->getTtlPrecision());
$this->assertGreaterThan(0, $capabilities->getTtlPrecision());

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

public function testKeyCapabilities()
Expand Down Expand Up @@ -602,7 +600,7 @@ public function testSetAndGetExpiredItem()
$this->assertNull($this->_storage->getItem('key'));

$this->_options->setTtl(0);
if ($capabilities->getExpiredRead()) {
if (! $capabilities->getStaticTtl()) {
$this->assertEquals('value', $this->_storage->getItem('key'));
} else {
$this->assertNull($this->_storage->getItem('key'));
Expand Down Expand Up @@ -647,7 +645,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 982a38c

Please sign in to comment.