优惠券订单及其他脚本

RedisClass.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. class RedisModel
  3. {
  4. public static $redis;
  5. private static function _init(){
  6. if( empty(self::$redis ) ){
  7. self::$redis = new Redis();
  8. self::$redis->connect('r-2ze28bdb7389a8a4.redis.rds.aliyuncs.com',6379);//链接
  9. self::$redis->auth('Zhuaduoduo2017');//密码
  10. }
  11. return self::$redis ;
  12. }
  13. public static function get( $key ){
  14. $redis = self::_init();
  15. return $redis->get($key);
  16. }
  17. public static function set( $key, $data){
  18. $redis = self::_init();
  19. return $redis->set( $key, $data);
  20. }
  21. public static function expire( $key, $time = 60 ){
  22. $redis = self::_init();
  23. return $redis->expire( $key, $time );
  24. }
  25. public static function setnx( $key, $data){
  26. $redis = self::_init();
  27. return $redis->setnx( $key, $data);
  28. }
  29. public static function srem( $key, $relation_id){
  30. $redis = self::_init();
  31. return $redis->srem( $key, $relation_id);
  32. }
  33. public static function del( $key ){
  34. $redis = self::_init();
  35. return $redis->del($key);
  36. }
  37. }