diff --git a/README.md b/README.md index fc78d44..16a92f2 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ # About -The `TarantoolStore` implements symfony `PersistingStoreInterface` and persist locks using Tarantool Database. +The `TarantoolStore` implements symfony `PersistingStoreInterface` using Tarantool Database. # Installation @@ -61,21 +61,21 @@ if ($lock->acquire()) { # Expiration helper -When key is expired it will be removed on acquiring new lock with same name. If your key names are not unique, you can use expiration daemon to cleanup your database. +When key is expired it will be removed on acquiring new lock with same name. If your key names are not unique, you can use php cleaner to cleanup your database. The best way to cleanup data is start a fiber inside tarantool. For more details see [expirationd module documentation](https://github.com/tarantool/expirationd) ```php use Tarantool\Client\Client; -use Tarantool\SymfonyLock\ExpirationDaemon; +use Tarantool\SymfonyLock\Cleaner; $client = Client::fromDefaults(); -$expiration = new ExpirationDaemon($client); +$cleaner = new Cleaner($client); // cleanup keys that are expired -$expiration->process(); +$cleaner->process(); -// by default expiration daemon will clean upto 100 items +// by default cleaner will process upto 100 items // you can override it via optional configuration -$expiration = new ExpirationDaemon($client, [ +$cleaner = new Cleaner($client, [ 'limit' => 10, ]); @@ -86,12 +86,12 @@ $expiration = new ExpirationDaemon($client, [ ```php use Tarantool\Client\Client; -use Tarantool\SymfonyLock\ExpirationDaemon; +use Tarantool\SymfonyLock\Cleaner; use Tarantool\SymfonyLock\SchemaManager; use Tarantool\SymfonyLock\TarantoolStore; $client = Client::fromDefaults(); -$expiration = new ExpirationDaemon($client, [ +$cleaner = new Cleaner($client, [ 'space' => 'lock', 'limit' => '100', ]); diff --git a/src/ExpirationDaemon.php b/src/Cleaner.php similarity index 98% rename from src/ExpirationDaemon.php rename to src/Cleaner.php index d4eabd3..36d9820 100644 --- a/src/ExpirationDaemon.php +++ b/src/Cleaner.php @@ -5,7 +5,7 @@ use Tarantool\Client\Client; use InvalidArgumentException; -class ExpirationDaemon +class Cleaner { use OptionalConstructor; diff --git a/tests/TarantoolStoreTest.php b/tests/TarantoolStoreTest.php index d2c482c..ddba549 100644 --- a/tests/TarantoolStoreTest.php +++ b/tests/TarantoolStoreTest.php @@ -8,7 +8,7 @@ use Symfony\Component\Lock\PersistingStoreInterface; use Tarantool\Client\Client; use Tarantool\Client\Schema\Criteria; -use Tarantool\SymfonyLock\ExpirationDaemon; +use Tarantool\SymfonyLock\Cleaner; use Tarantool\SymfonyLock\SchemaManager; use Tarantool\SymfonyLock\TarantoolStore; @@ -153,22 +153,22 @@ public function testPutOffExpiration() $this->assertNotSame($data[0][2], $updated[0][2], "expiration was updated"); } - public function testExpirationDaemon() + public function testCleaner() { $space = $this->client->getSpace('lock'); $space->insert([ 'key1', 'token', microtime(true) ]); $space->insert([ 'key2', 'token', microtime(true) ]); $space->insert([ 'key3', 'token', microtime(true) ]); - $expiration = new ExpirationDaemon($this->client); - $this->assertSame(3, $expiration->process()); + $cleaner = new Cleaner($this->client); + $this->assertSame(3, $cleaner->process()); $this->assertCount(0, $space->select(Criteria::key([]))); } - public function testExpirationDaemonLimit() + public function testCleanerLimit() { $space = $this->client->getSpace('lock'); - $expiration = new ExpirationDaemon($this->client, [ + $cleaner = new Cleaner($this->client, [ 'limit' => 1, ]); @@ -178,14 +178,14 @@ public function testExpirationDaemonLimit() $this->assertCount(3, $space->select(Criteria::key([]))); - $this->assertSame(1, $expiration->process()); + $this->assertSame(1, $cleaner->process()); $this->assertCount(2, $space->select(Criteria::key([]))); - $this->assertSame(1, $expiration->process()); + $this->assertSame(1, $cleaner->process()); $this->assertCount(1, $space->select(Criteria::key([]))); // last record is not expired - $this->assertSame(0, $expiration->process()); + $this->assertSame(0, $cleaner->process()); $this->assertCount(1, $space->select(Criteria::key([]))); } }