123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- class RedisModel
- {
- public static $redis;
- private static function _init(){
- if( empty(self::$redis ) ){
- self::$redis = new Redis();
- self::$redis->connect('r-2ze28bdb7389a8a4.redis.rds.aliyuncs.com',6379);//链接
- self::$redis->auth('Zhuaduoduo2017');//密码
- }
- return self::$redis ;
- }
- public static function get( $key ){
- $redis = self::_init();
- return $redis->get($key);
- }
- public static function set( $key, $data){
- $redis = self::_init();
- return $redis->set( $key, $data);
- }
- public static function expire( $key, $time = 60 ){
- $redis = self::_init();
- return $redis->expire( $key, $time );
- }
- public static function setnx( $key, $data){
- $redis = self::_init();
- return $redis->setnx( $key, $data);
- }
- public static function srem( $key, $relation_id){
- $redis = self::_init();
- return $redis->srem( $key, $relation_id);
- }
- public static function del( $key ){
- $redis = self::_init();
- return $redis->del($key);
- }
- }
|