Generation

generate functionTue, 27 Dec 2022

把历史记录记录到redis 并且最多20个,并返回所有记录,以最后写入的排第一个这样的顺序。

function get_history_data($key, $data, $max = 20) { $redis = $this->get_redis(); $redis->lPush($key, $data); $redis->lTrim($key, 0, $max - 1); $result = $redis->lRange($key, 0, -1); $redis->close(); return $result; }

Want to kickstart your project?Use the new AI Studio to create your code