Exemplo n.º 1
0
 function let(MetroFactory $factory, Redis $redis)
 {
     $this->beConstructedWith($factory);
     $factory->getRedis()->willReturn($redis);
     $factory->createKeyspace($redis)->willReturn(new Keyspace($redis->getWrappedObject()));
     Clock::setNowForTests(1429362976.2634);
 }
Exemplo n.º 2
0
 function let(MetroFactory $factory, Redis $redis, Redis $tx)
 {
     $this->beConstructedWith($this->createJob(), $factory);
     Clock::setNowForTests(1429362976.2634);
     $factory->getRedis()->willReturn($redis);
     $factory->createKeyspace($redis)->willReturn(new Keyspace($redis->getWrappedObject()));
     $factory->createKeyspace($tx)->willReturn(new Keyspace($tx->getWrappedObject()));
     $options['retry'] = 3;
     $options['cas'] = true;
     $redis->transaction($options, Argument::any())->will(function ($args) use($tx) {
         $args[1]($tx->getWrappedObject());
     });
 }
Exemplo n.º 3
0
 /**
  * @param string $jobId
  */
 public function add($jobId)
 {
     $this->redis->zadd($this->key, Clock::now()->timestamp(), $jobId);
 }
Exemplo n.º 4
0
 /**
  * @param string $jobId
  */
 public function add($jobId)
 {
     $timestamp = Clock::now()->timestamp();
     return $this->redis->zadd($this->key, $timestamp, $jobId);
 }
Exemplo n.º 5
0
 /** @return self */
 public function updateLastSeen()
 {
     $this->redis->hset($this->key, 'last-seen', Clock::now()->iso());
     return $this;
 }