123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * Created by: PhpStorm
- * User: lytian
- * Date: 2019/11/19
- * Time: 14:51
- */
- namespace app\common\model;
- use app\common\library\Redis;
- use think\Model;
- class WechatAb extends Model
- {
- // 表名
- protected $table = 'wechat_ab';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- public function getInfo($id)
- {
- $redisKey = 'WAB:'.$id;
- $data = Redis::instance()->hGetAll($redisKey);
- if (!$data) {
- $row = $this->where('id', 'eq', $id)->find();
- if ($row) {
- $data = $row->toArray();
- Redis::instance()->hMSet($redisKey, $data);
- Redis::instance()->expire($redisKey, 600);
- }
- }
- return $data;
- }
- public function delRedis($id)
- {
- $redisKey = 'WAB:'.$id;
- return Redis::instance()->del($redisKey);
- }
- }
|