正在显示
3 个修改的文件
包含
22 行增加
和
3 行删除
@@ -26,7 +26,7 @@ abstract class Base { | @@ -26,7 +26,7 @@ abstract class Base { | ||
26 | protected final function getEmails($filed='*'){ | 26 | protected final function getEmails($filed='*'){ |
27 | static $data; | 27 | static $data; |
28 | if(empty($data)){ | 28 | if(empty($data)){ |
29 | - $data = db()->all(emailSql::all(dbWhere(['email'=>web_request_emails()]))); | 29 | + $data = db()->cache(600)->all(emailSql::all(dbWhere(['email'=>web_request_emails()]))); |
30 | if(empty($data)){ | 30 | if(empty($data)){ |
31 | app()->e('email_request_required'); | 31 | app()->e('email_request_required'); |
32 | } | 32 | } |
@@ -138,10 +138,10 @@ class MailListV2 extends Base { | @@ -138,10 +138,10 @@ class MailListV2 extends Base { | ||
138 | 138 | ||
139 | //目录 | 139 | //目录 |
140 | // $where['folder_id'] = $folder_id; | 140 | // $where['folder_id'] = $folder_id; |
141 | - $where['_'] = $this->assignSql($folder); | 141 | + $where['_'] = trim(trim($this->assignSql($folder)),'and'); |
142 | }else{ | 142 | }else{ |
143 | // $where['lists|email_id'] = $this->getEmails('id'); | 143 | // $where['lists|email_id'] = $this->getEmails('id'); |
144 | - $where['_'] = $this->assignSql2(); | 144 | + $where['_'] = trim(trim($this->assignSql2()),'and'); |
145 | } | 145 | } |
146 | 146 | ||
147 | if($ids) $where['id'] = $ids; | 147 | if($ids) $where['id'] = $ids; |
@@ -321,6 +321,25 @@ trait DbQuery { | @@ -321,6 +321,25 @@ trait DbQuery { | ||
321 | * @time 2023/2/13 14:54 | 321 | * @time 2023/2/13 14:54 |
322 | */ | 322 | */ |
323 | public function all(string|array $sql){ | 323 | public function all(string|array $sql){ |
324 | + if($this->cache){ | ||
325 | + $key = 'data:'.md5(is_string($sql) ? $sql : json_encode($sql)); | ||
326 | + if(redis()->has($key)){ | ||
327 | + $this->cache = 0; | ||
328 | + return redis()->get($key,[]); | ||
329 | + } | ||
330 | + } | ||
331 | + $query = $this->query($sql); | ||
332 | + if($query){ | ||
333 | + $data = $query->fetchAll(); | ||
334 | + if($this->cache){ | ||
335 | + redis()->set($key,$data,$this->cache); | ||
336 | + $this->cache = 0; | ||
337 | + } | ||
338 | + return $data; | ||
339 | + } | ||
340 | + | ||
341 | + return []; | ||
342 | + | ||
324 | 343 | ||
325 | $query = $this->query($sql); | 344 | $query = $this->query($sql); |
326 | 345 |
-
请 注册 或 登录 后发表评论