Skip to content

Latest commit

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

🦄 FreeRedis

nugetstatsGitHub license

FreeRedis 是功能强大的 redis 客户端组件,支持 .NETCore 2.1+ 或 .NETFramework 4.0+ 或 Xamarin。

  • RedisClient Keep all method names consistent with redis-cli
  • Support geo type commands (redis-server 3.2 or above is required)
  • Support Redis Cluster
  • Support Redis Sentinel
  • Support Redis Master-Slave
  • Supports stream type commands (requires redis-server 5.0 and above)
  • Supports Redis 6 RESP3 Protocol

QQ群:4336577(已满)、8578575(在线)、52508226(在线)

Single machine redis (单机)

publicstaticRedisClientcli=newRedisClient("127.0.0.1:6379,password=123,defaultDatabase=13");varvalue=cli.Get("key1");
ParameterDefaultExplain
ProtocolRESP2If you use RESP3, you need redis 6.0 environment
user<Empty>Redis server username, requires redis-server 6.0
password<Empty>Redis server password
defaultDatabase0Redis server database
max pool size100Connection max pool size
min pool size5Connection min pool size
idleTimeout20000Idle time of elements in the connection pool (MS), suitable for connecting to remote redis server
connectTimeout5000Connection timeout (MS)
receiveTimeout10000Receive timeout (MS)
sendTimeout10000Send timeout (MS)
encodingutf-8string charset
sslfalseEnable encrypted transmission
name<Empty>Connection name, use client list command to view
prefix<Empty>key前辍,所有方法都会附带此前辍,cli.Set(prefix + "key", 111);

IPv6: [fe80::b164:55b3:4b4f:7ce6%15]:6379

Master-Slave (读写分离)

publicstaticcli=newRedisClient("127.0.0.1:6379,password=123,defaultDatabase=13","127.0.0.1:6380,password=123,defaultDatabase=13","127.0.0.1:6381,password=123,defaultDatabase=13");varvalue=cli.Get("key1");

内部读取数据时,随机连接 6380 6381 执行命令

Redis Sentinel (哨兵高可用)

publicstaticcli=newRedisClient("mymaster,password=123",new[]{"192.169.1.10:26379","192.169.1.11:26379","192.169.1.12:26379"},true);

哨兵高可用模式,第三个参数设置读写分离

Redis Cluster (集群)

待完成...

Pipeline (管道)

using(varpipe=cli.StartPipe()){pipe.IncrBy("key1",10);pipe.Set("key2",Null);pipe.Get("key1");object[]ret=pipe.EndPipe();}

Transaction (事务)

using(vartran=cli.Multi()){tran.IncrBy("key1",10);tran.Set("key2",Null);tran.Get("key1");object[]ret=tran.Exec();}

💕 Donation

Thank you for your donation

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages