Skip to content

Commit 642811d

Browse files
committed
existing logic no space support
1 parent a5395f7 commit 642811d

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

src/TarantoolStore.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ public function delete(Key $key, ?string $token = null)
7575
*/
7676
public function exists(Key $key)
7777
{
78-
$data = $this->getSpace()
79-
->select(Criteria::key([ (string) $key ]));
78+
try {
79+
$data = $this->client
80+
->getSpace($this->space)
81+
->select(Criteria::key([ (string) $key ]));
8082

81-
if (count($data)) {
82-
[$tuple] = $data;
83-
return $tuple[1] == $this->getUniqueToken($key)
84-
&& $tuple[2] >= microtime(true);
83+
if (count($data)) {
84+
[$tuple] = $data;
85+
return $tuple[1] == $this->getUniqueToken($key)
86+
&& $tuple[2] >= microtime(true);
87+
}
88+
} catch (RequestFailed $e) {
89+
// query failure means there is no valid space
90+
// it means that key is not exists in store
8591
}
8692
return false;
8793
}

tests/TarantoolStoreTest.php

+12
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,16 @@ public function testExpiredKeyOverwrite()
301301
$this->assertFalse($store->exists($key1));
302302
$this->assertTrue($store->exists($key2));
303303
}
304+
305+
public function testExistsOnDroppedSpace()
306+
{
307+
$key = new Key(uniqid(__METHOD__, true));
308+
309+
$store = $this->getStore();
310+
$store->save($key);
311+
312+
$this->schema->tearDown();
313+
314+
$this->assertFalse($store->exists($key));
315+
}
304316
}

0 commit comments

Comments
 (0)