123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Bear
- * Date: 2019/5/14
- * Time: 上午9:40
- */
- namespace app\common\model;
- use app\common\library\Redis;
- use app\main\constants\CacheConstants;
- use think\Model;
- class ChapterEdited extends Model
- {
- protected $pk = 'chapter_id';
- // 表名
- protected $table = 'chapter_edited';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'create_time';
- protected $updateTime = 'update_time';
- public function getChapterFromDb($chapter_id)
- {
- $cacheKey = CacheConstants::BOOK_EDITED_CHAPTER . $chapter_id;
- if ($data = Redis::instance()->get($cacheKey)) {
- $decode = json_decode($data, true);
- $decode['content'] = str_replace(['<p>', '</p>'], ['', "\n"], $decode['content']);
- return $decode;
- } else {
- return false;
- }
- }
- }
|