- https://www.cnblogs.com/liuqingzheng/p/9831331.html
redis.windows-service.conf
RedisDesktopManager
连接本地
redis-cli ping
如果出现NOAUTH
,则需要输入密码auth pwd
。
keys *
select 2
ttl key
nuget 包StackExchange.Redis
- https://www.cnblogs.com/cang12138/p/8884362.html
ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("10.11.22.1:6379,10.11.22.1:6379,10.11.22.1:6379,password=123456"); IDatabase db = redis.GetDatabase(0); db.StringSet("1", "2"); var val = db.StringGet("1");
- https://www.cnblogs.com/xscape/p/10208638.html
var csredis = new CSRedisClient("127.0.0.1:6379,password=123456"); // RedisHelper.Initialization(csredis); Console.WriteLine(string.Join(',', csredis.Keys("*"))); csredis.Set("user1", new User { Name = "user1",Age=10 }); Console.WriteLine(csredis.Get("user1")); //过期时间 //csredis.Set("user2", new User { Name = "user2" },3); //Console.WriteLine(csredis.Get("user2")); //System.Threading.Thread.Sleep(4000); //Console.WriteLine("过了时间段查询:"+csredis.Get("user2")); //批量删除通配符key var keyList= _redisDb._client.Keys("alex.system:play.info*").Select(a=> { return a.Replace("alex.system:", ""); }).ToArray(); var a2= _redisDb._client.Del(keyList);
封装了一层简单帮助类
public class RedisCacheHelper { private readonly CSRedisClient _client; public RedisCacheHelper( ) { _client= new CSRedisClient("127.0.0.1:6379,password=123456"); } /// <summary> /// 添加,如果存在则替换 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> /// <param name="val"></param> /// <param name="expireSecond"></param> public void Set<T>(string key,T val,int expireSecond=-1) { _client.Set(key, val,expireSecond); } public T Get<T>(string key) { return _client.Get<T>(key); } public bool Exists(string key) { return _client.Exists(key); } public void Remove(string key) { _client.Del(key); } }
- https://www.cnblogs.com/gygtech/p/14872036.html
"Cache": "localhost:6379,password=123456,preheat=5,idleTimeout=600,defaultDatabase=13,prefix=Cache"
:
- https://www.runoob.com/w3cnote/python-redis-intro.html
pip install redis
partially initialized module 'redis' has no attribute 'ConnectionPool' (most likely due to a circular import)
redis.py
ex - 过期时间(秒)
import redis # con='localhost:6379,password=123456,preheat=5,idleTimeout=600,defaultDatabase=02,prefix=alex.system.' # 厉害了,python找不到 prefix prefix='alex.system.' pool = redis.ConnectionPool(host='localhost',port=6379,password='123456',db='02',decode_responses=True) redisDb= redis.Redis(connection_pool=pool) a1=redisDb.get("fund.list") print(type(a1))