Skip to content

Commit

Permalink
text expired key overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Jun 24, 2020
1 parent 999cfca commit a5395f7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/TarantoolStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Tarantool\Client\Client;
use Tarantool\Client\Exception\RequestFailed;
use Tarantool\Client\Schema\Criteria;
use Tarantool\Client\Schema\Operations;
use Tarantool\SymfonyLock\Cleaner;
use Tarantool\SymfonyLock\SchemaManager;
use Tarantool\SymfonyLock\TarantoolStore;
Expand Down Expand Up @@ -275,4 +276,29 @@ public function testDefaultSchemaCreationIsDisabled()
$store = new TarantoolStore($client);
$store->save(new Key(uniqid(__METHOD__, true)));
}

public function testExpiredKeyOverwrite()
{
$resource = uniqid(__METHOD__, true);
$key1 = new Key($resource);
$key2 = new Key($resource);

$store = $this->getStore();

$store->save($key1);
$this->assertTrue($store->exists($key1));
$this->assertFalse($store->exists($key2));

$rows = $this->client->getSpace('lock')->select(Criteria::key([]));
$this->assertCount(1, $rows);
$this->client->getSpace('lock')->update([$rows[0][0]], Operations::set(2, microtime(true)));

$this->assertFalse($store->exists($key1));
$this->assertFalse($store->exists($key2));

$store->save($key2);

$this->assertFalse($store->exists($key1));
$this->assertTrue($store->exists($key2));
}
}

0 comments on commit a5395f7

Please sign in to comment.