/**
  * @inheritdoc
  */
 public function has(AggregateIdInterface $id, $version)
 {
     if (!$this->redis->hexists(static::KEY_NAMESPACE, (string) $id)) {
         return false;
     }
     $snapshot = $this->serializer->deserialize($this->redis->hget(static::KEY_NAMESPACE, (string) $id), 'array', 'json');
     return $snapshot['version'] === $version;
 }
 /**
  * @param $id
  * @param $expectedDeserializedRedisData
  */
 protected function mockRedisHasAndGetData($id, $expectedDeserializedRedisData)
 {
     $this->client->hexists(RedisSnapshotAdapter::KEY_NAMESPACE, (string) $id)->willReturn(true)->shouldBeCalledTimes(1);
     $this->client->hget(RedisSnapshotAdapter::KEY_NAMESPACE, (string) $id)->willReturn('redis_data')->shouldBeCalledTimes(1);
     $this->serializer->deserialize('redis_data', 'array', 'json')->willReturn($expectedDeserializedRedisData);
 }
Exemple #3
0
 /**
  * @group redis-hashes
  */
 public function testHashExists()
 {
     $this->assertFalse($this->client->hexists('foo', 'hello'));
     $this->client->hset('foo', 'hello', 'world');
     $this->assertTrue($this->client->hexists('foo', 'hello'));
 }