Coder Social home page Coder Social logo

Comments (8)

2881099 avatar 2881099 commented on July 17, 2024

object 支持 string 和 byte[]

from csredis.

2881099 avatar 2881099 commented on July 17, 2024

存 byte[] 的话不需要序列化

from csredis.

2881099 avatar 2881099 commented on July 17, 2024
//
	// 摘要:
	//     只有在字段 field 不存在时,设置哈希表字段的值。
	//
	// 参数:
	//   key:
	//     不含prefix前辍
	//
	//   field:
	//     字段
	//
	//   value:
	//     值(string 或 byte[])
	public static bool HashSetNx(string key, string field, object value);

注释有标明的。

from csredis.

shenlanchenwei avatar shenlanchenwei commented on July 17, 2024

你好再请教一个问题,我现在Redis只有主从模式,没有集群模式
有这个(主从)的配置示例吗?
没有看到相关示例,非常感谢!!

from csredis.

2881099 avatar 2881099 commented on July 17, 2024

主从模式要使用 CSRedis.RedisSentinelClient,目前没有封装到 CSRedisClient 和 RedisHelper 中。

from csredis.

2881099 avatar 2881099 commented on July 17, 2024
using (var sentinel = new RedisSentinelManager("host1:123", "host2:456"))
{
    sentinel.Add(Host); // add host using default port 
    sentinel.Add(Host, 36379); // add host using specific port
    sentinel.Connected += (s, e) => sentinel.Call(x => x.Auth(Password)); // this will be called each time a master connects
    sentinel.Connect("mymaster"); // open connection
    var test2 = sentinel.Call(x => x.Time()); // use the Call() lambda to access the current master connection
}

from csredis.

shenlanchenwei avatar shenlanchenwei commented on July 17, 2024

谢谢了!!!

from csredis.

2881099 avatar 2881099 commented on July 17, 2024

CSRedisClient 和 RedisHelper 提供的集群模式功能,也可以现实高可用。

static redis1 = new CSRedisClient("192.168.1.9:6379,password=,defaultDatabase=1,poolsize=1");
static redis2 = new CSRedisClient("192.168.1.9:6379,password=,defaultDatabase=2,poolsize=1");

var client = new CSRedisClient(
	key => {
		//在这里判断服务有效性
		try { redis1.Ping(); return "192.168.1.9:6379/1"; } catch { }
		try { redis2.Ping(); return "192.168.1.9:6379/2"; } catch { }
		return "192.168.1.9:6379/1";
	},
	"192.168.1.9:6379,password=,defaultDatabase=1",
	"192.168.1.9:6379,password=,defaultDatabase=2");

这个做法有点生硬,之后会优化。

from csredis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.