mirror of
https://github.com/friendica/friendica
synced 2025-05-04 09:04:11 +02:00
Added Unittests for cache
fixed Lock & Cache bugs
This commit is contained in:
parent
1dafaa69c5
commit
80a4e6263f
18 changed files with 317 additions and 25 deletions
|
@ -24,4 +24,10 @@ class ArrayCacheLockDriverTest extends LockTest
|
|||
$this->cache->clear();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testLockTTL()
|
||||
{
|
||||
// ArrayCache doesn't support TTL
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,24 @@ abstract class LockTest extends DatabaseTest
|
|||
$this->assertFalse($this->instance->isLocked('bar'));
|
||||
$this->assertFalse($this->instance->isLocked('nice'));
|
||||
}
|
||||
|
||||
function testLockTTL() {
|
||||
|
||||
// TODO [nupplaphil] - Because of the Datetime-Utils for the database, we have to wait a FULL second between the checks to invalidate the db-locks/cache
|
||||
$this->instance->acquireLock('foo', 1, 1);
|
||||
$this->instance->acquireLock('bar', 1, 3);
|
||||
|
||||
$this->assertTrue($this->instance->isLocked('foo'));
|
||||
$this->assertTrue($this->instance->isLocked('bar'));
|
||||
|
||||
sleep(2);
|
||||
|
||||
$this->assertFalse($this->instance->isLocked('foo'));
|
||||
$this->assertTrue($this->instance->isLocked('bar'));
|
||||
|
||||
sleep(2);
|
||||
|
||||
$this->assertFalse($this->instance->isLocked('foo'));
|
||||
$this->assertFalse($this->instance->isLocked('bar'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,10 @@ class SemaphoreLockDriverTest extends LockTest
|
|||
$this->semaphoreLockDriver->releaseAll();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
function testLockTTL()
|
||||
{
|
||||
// Semaphore doesn't work with TTL
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue