mirror of
https://github.com/friendica/friendica
synced 2024-11-10 02:22:55 +00:00
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:
parent
c9d829a679
commit
91f5a7cc6b
4 changed files with 32 additions and 1 deletions
|
@ -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)
|
* (@inheritdoc)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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)
|
* (@inheritdoc)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2017,7 +2017,7 @@ class OStatus
|
||||||
* cache or it is empty
|
* cache or it is empty
|
||||||
*
|
*
|
||||||
* @param string $owner_nick Nickname of the feed owner
|
* @param string $owner_nick Nickname of the feed owner
|
||||||
* @param string $last_update Date of the last update
|
* @param string $last_update Date of the last update (in "Y-m-d H:i:s" format)
|
||||||
* @param integer $max_items Number of maximum items to fetch
|
* @param integer $max_items Number of maximum items to fetch
|
||||||
* @param string $filter Feed items filter (activity, posts or comments)
|
* @param string $filter Feed items filter (activity, posts or comments)
|
||||||
* @param boolean $nocache Wether to bypass caching
|
* @param boolean $nocache Wether to bypass caching
|
||||||
|
|
|
@ -237,4 +237,13 @@ abstract class CacheTest extends MockedTest
|
||||||
self::assertNotContains('value1', $list);
|
self::assertNotContains('value1', $list);
|
||||||
self::assertNotContains('value2', $list);
|
self::assertNotContains('value2', $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @small
|
||||||
|
*/
|
||||||
|
public function testSpaceInKey()
|
||||||
|
{
|
||||||
|
self::assertTrue($this->instance->set('key space', 'value'));
|
||||||
|
self::assertEquals('value', $this->instance->get('key space'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue