tedious / Stash

The place to keep your cache.
http://www.stashphp.com
BSD 3-Clause "New" or "Revised" License
962 stars 133 forks source link

Redis items aren't really deleted? #382

Closed walterdl closed 5 years ago

walterdl commented 6 years ago

Hi there,

I've noticed that items stored using Redis driver aren't never really deleted. Their values keep in database and a new key is created with an autoincrement, but when you get the value of the supposed deleted item is null. Example:

  // here just create an item
  // init driver and pool
  $driver = new Stash\Driver\Redis();
  $pool = new Stash\Pool($driver);

  // create an item
  $toCreate = $pool->getItem('/foo/bar');
  $toCreate->set('hello there');
  $toCreate->save();

  // the value is showed, everything fine until here
  echo $toCreate->get();
  // in other request ...
  // here delete the item
  $pool->deleteItem('/foo/bar');

  // get the item
  $deletedItem = $pool->getItem('/foo/bar');

  // this is null
  echo $deletedItem->get();

Using a client with GUI you can see that the item never is deleted, instead a new key is created with an autoincrement and every time that you try to delete the item this integer value becomes higher.

This is a normal behavior? With this the database never is cleared!

Redis version: 3.0.504 Stash version: v0.14.1 php version: 5.6

tedivm commented 5 years ago

This is expected behavior- the older items will expire out of the cache.