...
|
...
|
@@ -321,6 +321,25 @@ trait DbQuery { |
|
|
* @time 2023/2/13 14:54
|
|
|
*/
|
|
|
public function all(string|array $sql){
|
|
|
if($this->cache){
|
|
|
$key = 'data:'.md5(is_string($sql) ? $sql : json_encode($sql));
|
|
|
if(redis()->has($key)){
|
|
|
$this->cache = 0;
|
|
|
return redis()->get($key,[]);
|
|
|
}
|
|
|
}
|
|
|
$query = $this->query($sql);
|
|
|
if($query){
|
|
|
$data = $query->fetchAll();
|
|
|
if($this->cache){
|
|
|
redis()->set($key,$data,$this->cache);
|
|
|
$this->cache = 0;
|
|
|
}
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
return [];
|
|
|
|
|
|
|
|
|
$query = $this->query($sql);
|
|
|
|
...
|
...
|
|