Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * @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);
 }
Ejemplo n.º 3
0
 /**
  * @group redis-hashes
  */
 public function testHashGet()
 {
     $this->assertNull($this->client->hget('foo', 'bar'));
     $this->client->hset('foo', 'bar', 'hello');
     $this->assertEquals('hello', $this->client->hget('foo', 'bar'));
 }