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); }
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()); }); }
/** * @param string $jobId */ public function add($jobId) { $this->redis->zadd($this->key, Clock::now()->timestamp(), $jobId); }
/** * @param string $jobId */ public function add($jobId) { $timestamp = Clock::now()->timestamp(); return $this->redis->zadd($this->key, $timestamp, $jobId); }
/** @return self */ public function updateLastSeen() { $this->redis->hset($this->key, 'last-seen', Clock::now()->iso()); return $this; }