Skip to content

Commit

Permalink
fix cleaner name
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Jun 23, 2020
1 parent 2f61970 commit 128f069
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
]);

Expand All @@ -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',
]);
Expand Down
2 changes: 1 addition & 1 deletion src/ExpirationDaemon.php → src/Cleaner.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Tarantool\Client\Client;
use InvalidArgumentException;

class ExpirationDaemon
class Cleaner
{
use OptionalConstructor;

Expand Down
18 changes: 9 additions & 9 deletions tests/TarantoolStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
]);

Expand All @@ -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([])));
}
}

0 comments on commit 128f069

Please sign in to comment.