Rediska_Zend_Cache_Backend_Redis, supporting tags, 'infinite life' and cleaning. #63

Merged
merged 10 commits into from May 29, 2012

Projects

None yet

3 participants

@zircote
zircote commented May 20, 2012

Implemented support for cache cleaning via the Rediska_Zend_Cache_Backend_Redis adapter.

Methods now active are:

  • getIds
  • getTags
  • getIdsMatchingTags
  • getIdsNotMatchingTags
  • getIdsMatchingAnyTags

Added a backend options:

  • storage
    • set_ids : the set name that all ids are storage
    • set_tags : the set name that stores the tags
    • prefix_key : the prefix value for all item keys
    • prefix_tag_ids : the key prefix value for all tag-to-id items
zircote added some commits May 19, 2012
@zircote zircote implemented suggestions made by @shumkov
The cache now implements transactions for the delete process and garbageCollection.
All data now is stored as hashes, as  as follows:
 this approach is much cleaner and efficient.
It also make better use of many of Rediskas features ie. transactions as well as
redis' hash and set tool.

Tests have been updated and added to reflect these changes.

@todo: it may be possible (if not necasary) to place a watch on certain meta
data sets for the garbage collection to ensure it does not change before the
is executes. This has yet to be determined.
cb838fd
@zircote zircote reverted erronious changes made to CLEAN_MODE_ALL
restored original approach to flushing the DB for CLEAN_MODEL_ALL
89f9a64
@zircote zircote more work addressing cleanup and purge d435e51
@zircote zircote moved the prefixing and table to backend config options
Updated the tests to the changes
added the config settings to two of the four application.ini examples
for the resource/cachemanager use of the rediska cache backend.
54c98b4
@zircote zircote moved the prefixing and table to backend config options
Updated the tests to the changes
added the config settings to two of the four application.ini examples
for the resource/cachemanager use of the rediska cache backend.
43032df
@zircote zircote Merge branch 'zend_cache_backend' of github.com:zircote/Rediska into …
…zend_cache_backend
d6b31a5
@zircote zircote refactored naming of protected methods to begin with _ d42017f
@dospromptman dospromptman commented on an outdated diff May 22, 2012
library/Rediska/Zend/Cache/Backend/Redis.php
/**
* Contruct Zend_Cache Redis backend
- *
+ *
+ * Available optiosn are :
@dospromptman dospromptman commented on an outdated diff May 22, 2012
library/Rediska/Zend/Cache/Backend/Redis.php
@@ -206,7 +402,7 @@ public function setDirectives($directives)
{
parent::setDirectives($directives);
$lifetime = $this->getLifetime(false);
- if ($lifetime > 2592000) {
+ if ($lifetime > self::MAX_LIFETIME) {
$this->_log('redis backend has a limit of 30 days (2592000 seconds) for the lifetime');
@dospromptman
dospromptman May 22, 2012

Consider using MAX_LIFETIME in the log message, also?

@Shumkov

You can only get a hash and if returns null, you return false

Owner

You can get array of ids for backward compatibility

@Shumkov

Why? Optimization? May be create transation from rediska on each method?

@Shumkov

execute returns array of all commands responses. You can return first element (response from delete)

@Shumkov

Hash fields has order?

@Shumkov

Very difficult expression

Owner
$lifetime = $this->getRediska()->getLifetime(self::PREFIX_KEY.$id);
$expire = $infinite === '1' ? false : time() + $lifetime;
@Shumkov

$data[self::FIELD_INF]?

@Shumkov

Very difficult expression

Owner
$lifeTime =  $this->getRediska()->getLifetime(self::PREFIX_KEY.$id);
$expireAt = time() + $lifeTime + $extraLifetime;
zircote added some commits May 22, 2012
@zircote zircote applied feedback from code review:
 * corrected bug with `getHashValues` changed to `getFromHash`
 * removed `_getTransaction` method in favor of `$this->getRediska()->transaction();`
 * corrected `load` to support array of IDs in addition to single IDs
 * corrected `load` to return false when data is `null` even if the key is valid
0943794
@zircote zircote corrected typo in docblock, and exception message
changed exception message for max life of key to utilize same constant as the test
58cf198
@zircote
zircote commented May 22, 2012

Corrections made:

  • corrected bug with getHashValues changed to getFromHash (nice catch @shumkov )
  • removed _getTransaction method in favor of $this->getRediska()->transaction();
  • corrected load to support array of IDs in addition to single IDs
  • corrected load to return false when data is null

@Shumkov do you have a suggestion regarding the expire time expression you have noted.

@zircote zircote Simplified the expressions related to the lifetime:
methods -
 * `touch`
 * `getMetadatas`
f5bfaba
@zircote
zircote commented May 26, 2012

@Shumkov are there any other items you would have me address?

@Shumkov
Owner
Shumkov commented May 29, 2012

Nice job Robert!

@Shumkov Shumkov merged commit bf55024 into Shumkov:master May 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment