Convert potential spaces in Memcache(d) key names

- Address https://github.com/friendica/friendica/issues/11630#issuecomment-1166475036
- Add test for space in cache keys
This commit is contained in:
Hypolite Petovan 2022-06-26 05:56:13 -04:00
parent c9d829a679
commit 91f5a7cc6b
4 changed files with 32 additions and 1 deletions

View file

@ -68,6 +68,17 @@ class MemcacheCache extends AbstractCache implements ICanCacheInMemory
}
}
/**
* Memcache doesn't allow spaces in keys
*
* @param string $key
* @return string
*/
protected function getCacheKey(string $key): string
{
return str_replace(' ', '_', parent::getCacheKey($key));
}
/**
* (@inheritdoc)
*/

View file

@ -93,6 +93,17 @@ class MemcachedCache extends AbstractCache implements ICanCacheInMemory
}
}
/**
* Memcached doesn't allow spaces in keys
*
* @param string $key
* @return string
*/
protected function getCacheKey(string $key): string
{
return str_replace(' ', '_', parent::getCacheKey($key));
}
/**
* (@inheritdoc)
*/