排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

Nuget下载:
Install-Package StackExchange.Redis -Version 2.0.519
hash表相关
获取所有键值,与所有value
public void HashOpe() { IDatabase idb = SingletonRedis.GetInstance(); //获取所有的Hash键值对 var indexArt = idb.HashGetAll("indexArticle"); //获取hash的所有value RedisValue[] redisValues = idb.HashValues("indexArticle"); }
给hash添加一个键值
public static void SetUserKV(string username, string userid) { IDatabase redis = SingletonRedis.GetInstance(); redis.HashSet("ukv", username, userid); }
判断是否存在与获取值
public static string GetUserIdByName(string username) { IDatabase redis = SingletonRedis.GetInstance(); //键是否存在 if (!redis.HashExists("ukv", username)) { return null; } //获取值 return redis.HashGet("ukv", username); }
基础键值对
判断键是否存在
idb.KeyExists("VisitLog")
添加一个值
idb.StringSet("VisitLog",1);
获取一个值
idb.StringGet("VisitLog")
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价