public function storeContent() { $name = $_POST['name']; $final = $_POST['final']; $advantages = $_POST['ad']; $disadvantages = $_POST['dis']; $retID = pass_passService::getUid(); if (!$retID) { $result['errNum'] = '0007'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $this->renderJson($result); } $content = array('name' => $name, 'final' => $final, 'ad' => $advantages, 'dis' => $disadvantages); $redis = redisModel::getInstance(); $key = sprintf(self::REDIS_DECISION_USER_KEY, $retID); $ret = $redis::$redis->lPush($key, json_encode($content)); if (!$ret) { log::warning("redis write error", "log.wf"); $result['errNum'] = '0005'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $this->renderJson($result); } $result['errNum'] = '0000'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $this->renderJson($result); }
public function __construct() { $dbConfig = (require CONF_PATH . "redis.conf.php"); self::$redis = new redis(); $ret = self::$redis->connect($dbConfig["host"], $dbConfig["port"]); if (!$ret) { log::warning("redis connect error", "log.wf"); } }
public function getContent() { $retID = pass_passService::getUid(); if (!$retID) { $result['errNum'] = '0007'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $this->renderJson($result); } $redis = redisModel::getInstance(); $key = sprintf(self::REDIS_DECISION_USER_KEY, $retID); $ret = $redis::$redis->lRange($key, 0, 9); foreach ($ret as $key => $value) { $ret[$key] = json_decode($value, true); } if (empty($ret)) { $result['errNum'] = '0008'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $this->renderJson($result); } $result['errNum'] = '0000'; $result['errMsg'] = errorcode::$error[$result['errNum']]; $result['content'] = $ret; $this->renderJson($result); }
public function init($isbn) { parent::init($isbn); $this->doubanUrl = 'http://book.douban.com/isbn/' . $isbn; // dd($this->getKey()); }