[Spanner] CacheSessionPool::clear deletes the entire cache
taka-oyama opened this issue · 4 comments
taka-oyama commented
It shouldn't be doing that.
It should only delete the key(s) that are relevant.
Environment details
Irrelevant.
Steps to reproduce
- Set unrelated item to the CacheItemPool
- create new CacheSessionPool using CacheItemPool
- Call CacheSessionPool::clear()
Code example
$cache = new \Symfony\Component\Cache\Adapter\ArrayAdapter();
// set an unrelated item
$item = $cache->getItem('dummy')->set('hi');
$cache->save($item);
$connection = (new SpannerClient())->connect(
getenv('SPANNER_INSTANCE'),
getenv('SPANNER_DATABASE'),
['sessionPool' => new CacheSessionPool($cache)],
);
var_dump($cache->hasItem('dummy')); // true
$connection->sessionPool()?->clear();
var_dump($cache->hasItem('dummy')); // false
See the code below.
This should probably be $this->cacheItemPool->deleteItem($item);
.