Bugfixings for Cache-Lock

- used wrong cachekey in set
- therefore added an abstraction to avoid wrong key concatenation
- forgot to increase the db-version to 1275
This commit is contained in:
Philipp Holzer 2018-07-05 21:47:52 +02:00
parent 3be013361e
commit 34cea93a8b
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6
7 changed files with 72 additions and 35 deletions

View file

@ -29,7 +29,7 @@ class CacheLockDriver extends AbstractLockDriver
$got_lock = false;
$start = time();
$cachekey = self::getCacheKey($key);
$cachekey = self::getLockKey($key);
do {
$lock = $this->cache->get($cachekey);
@ -62,7 +62,7 @@ class CacheLockDriver extends AbstractLockDriver
*/
public function releaseLock($key)
{
$cachekey = self::getCacheKey($key);
$cachekey = self::getLockKey($key);
$this->cache->compareDelete($cachekey, getmypid());
$this->markRelease($key);
@ -73,7 +73,7 @@ class CacheLockDriver extends AbstractLockDriver
*/
public function isLocked($key)
{
$cachekey = self::getCacheKey($key);
$cachekey = self::getLockKey($key);
$lock = $this->cache->get($cachekey);
return isset($lock) && ($lock !== false);
}
@ -82,7 +82,7 @@ class CacheLockDriver extends AbstractLockDriver
* @param string $key The original key
* @return string The cache key used for the cache
*/
private static function getCacheKey($key) {
return self::getApp()->get_hostname() . ";lock:" . $key;
private static function getLockKey($key) {
return "lock:" . $key;
}
}