1. 程式人生 > >我的封裝的redis

我的封裝的redis

<?php class redis_server{ protected $_server = null; public function __construct(){ //parent::__construct(); $this->_server = new redis(); $result = $this->_server->connect('127.0.0.1',6379); if(!$result){ $this->_server = null; } return $this->_server; } public function set($key,$value){ $res = $this->_server->lpush($key,$value); print_r($res); } public function get($key){ $res = $this->_server->rpop($key); print_r($res); } } $model = new redis_server(); // $model->set('list','閃只想'); $model ->get('list');