public function testManageMessage() { $this->createMocks(); $redisConnection = m::mock("Predis\\Client"); $this->message->shouldReceive("newInstance")->once()->andReturnSelf(); $this->message->shouldReceive("save")->once(); $this->message->shouldReceive("offsetGet")->once()->with(EloquentMessageRepository::TIME_PLACED)->andReturnSelf(); $this->message->shouldReceive("offsetSet")->once()->with(EloquentMessageRepository::TIME_PLACED, "dummy date"); $this->message->shouldReceive("offsetGet")->once()->with(EloquentMessageRepository::AMOUNT_BUY)->andReturn("100.1"); $this->message->shouldReceive("offsetSet")->once()->with(EloquentMessageRepository::AMOUNT_BUY, "100.10"); $this->message->shouldReceive("offsetGet")->once()->with(EloquentMessageRepository::AMOUNT_SELL)->andReturn("45"); $this->message->shouldReceive("offsetSet")->once()->with(EloquentMessageRepository::AMOUNT_SELL, "45.00"); $this->message->shouldReceive("offsetGet")->once()->with(EloquentMessageRepository::RATE)->andReturn("4.23"); $this->message->shouldReceive("offsetSet")->once()->with(EloquentMessageRepository::RATE, "4.2300"); $this->message->shouldReceive("toDateTimeString")->once()->andReturn("dummy date"); $this->message->shouldReceive("toJson")->once()->andReturn("dummy json"); \LRedis::shouldReceive("connection")->once()->andReturn($redisConnection); $redisConnection->shouldReceive("publish")->once()->with("message", "dummy json"); $this->messageRepository->manageMessages(new ParameterBag($this->getMessageDummy())); }
public function IsHas($name) { $redis = LRedis::connection(); $ret = $redis->exists($name); if ($ret == 1) { return true; } return false; }
/** * Execute the job. * * @return void */ public function handle() { $date = date('H:i:s'); \LRedis::SETEX('PUSH-' . $date . '-' . $this->uid, 300, $this->message); // pushMessage($this->uid, $this->message,$this->extras); }
public function IsExist() { $redis = LRedis::connection(); $ret = $redis->exists(self::buildCacheKey()); if ($ret == 1) { return true; } return false; }
public function getCode() { $phone = \Input::get('phone'); $key = \App\Services\User\UserService::getRedisKeys('smsKey', [date('Ymd'), $phone]); $data = \LRedis::GET($key); $data && ($data = json_decode($data, 1)); $last = end($data); return $this->__json(200, 'ok', $last); }
function getOnlineIp() { $OnlineIp = \LRedis::GET('OnlineIp'); if (!$OnlineIp) { $url = 'http://city.ip138.com/ip2city.asp'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 8); $send_result = curl_exec($ch); if ($send_result === false) { throw new \Exception("REQ[{$url}]" . curl_error($ch), curl_errno($ch) + 60000); } preg_match('/\\[(.*)\\]/', $send_result, $ip); $OnlineIp = $ip[1]; \LRedis::SETEX('OnlineIp', 6000, $OnlineIp); } return $OnlineIp; }
function redis_publish($channel, $data) { return \LRedis::publish($channel, json_encode($data)); }
public function sendMessage() { $redis = \LRedis::connection(); $redis->publish('1', json_encode(['action' => \Request::input('action'), 'data' => \Request::input('message')])); return redirect('writemessage'); }