Fixed memcache & unittests
This commit is contained in:
parent
80a4e6263f
commit
065b83d148
|
@ -21,3 +21,4 @@ before_script:
|
||||||
- mysql -utravis test < database.sql
|
- mysql -utravis test < database.sql
|
||||||
- echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
- echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||||
- echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
- echo "extension=memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
||||||
|
- echo "extension=memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
|
|
@ -111,6 +111,6 @@ class MemcacheCacheDriver extends AbstractCacheDriver implements IMemoryCacheDri
|
||||||
public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
|
public function add($key, $value, $ttl = Cache::FIVE_MINUTES)
|
||||||
{
|
{
|
||||||
$cachekey = $this->getCacheKey($key);
|
$cachekey = $this->getCacheKey($key);
|
||||||
return $this->memcache->add($cachekey, $value, $ttl);
|
return $this->memcache->add($cachekey, serialize($value), MEMCACHE_COMPRESSED, $ttl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
39
tests/src/Core/Cache/MemcacheCacheDriverTest.php
Normal file
39
tests/src/Core/Cache/MemcacheCacheDriverTest.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Friendica\Test\src\Core\Cache;
|
||||||
|
|
||||||
|
|
||||||
|
use Friendica\Core\Cache\CacheDriverFactory;
|
||||||
|
|
||||||
|
class MemcachedCacheDriverTest extends CacheTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Friendica\Core\Cache\IMemoryCacheDriver
|
||||||
|
*/
|
||||||
|
private $cache;
|
||||||
|
|
||||||
|
protected function getInstance()
|
||||||
|
{
|
||||||
|
if (class_exists('Memcache')) {
|
||||||
|
try {
|
||||||
|
$this->cache = CacheDriverFactory::create('memcache');
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
print "Memcache - TestCase failed: " . $exception->getMessage();
|
||||||
|
throw new \Exception();
|
||||||
|
}
|
||||||
|
return $this->cache;
|
||||||
|
} else {
|
||||||
|
$this->markTestSkipped('Memcache driver isn\'t available');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
if (class_exists('Memcache')) {
|
||||||
|
$this->cache->clear();
|
||||||
|
}
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
}
|
40
tests/src/Core/Lock/MemcacheCacheLockDriverTest.php
Normal file
40
tests/src/Core/Lock/MemcacheCacheLockDriverTest.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Friendica\Test\src\Core\Lock;
|
||||||
|
|
||||||
|
|
||||||
|
use Friendica\Core\Cache\CacheDriverFactory;
|
||||||
|
use Friendica\Core\Lock\CacheLockDriver;
|
||||||
|
|
||||||
|
class MemcacheCacheLockDriverTest extends LockTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Friendica\Core\Cache\IMemoryCacheDriver
|
||||||
|
*/
|
||||||
|
private $cache;
|
||||||
|
|
||||||
|
protected function getInstance()
|
||||||
|
{
|
||||||
|
if (class_exists('Memcache')) {
|
||||||
|
try {
|
||||||
|
$this->cache = CacheDriverFactory::create('memcache');
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
print "Memcache - TestCase failed: " . $exception->getMessage();
|
||||||
|
throw new \Exception();
|
||||||
|
}
|
||||||
|
return new CacheLockDriver($this->cache);
|
||||||
|
} else {
|
||||||
|
$this->markTestSkipped('Memcache driver isn\'t available');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
if (class_exists('Memcache')) {
|
||||||
|
$this->cache->clear();
|
||||||
|
}
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue