BAE使用Redis作为内存缓存
程序员文章站
2022-04-27 15:11:31
...
BAE内存缓存(phpRedis)
<?php /* * Redis Cache */ class cache { private $redis = null;//only this class private $mysql = null; public function __construct($host, $port, $username, $password, $database) { if (!class_exists('Redis')) return false; try { $this->redis = new Redis(); $this->redis->connect($host, $port, '0.2');//timeout 200ms $this->redis->auth("{$username}-{$password}-{$database}"); } catch (RedisException $error) { return false; //var_dump($error); } } public function get($key) { return $this->redis->get($key); } public function set($key, $value, $express=0) { if ($express) return $this->redis->setex($key, $express, $value); else return $this->redis->set($key, $value); } public function delete($key) { return $this->redis->delete($key); } }
下一篇: Oracle还原和创建用户dmp文件