ideawu / ssdb

SSDB - A fast NoSQL database, an alternative to Redis
http://ssdb.io/
BSD 3-Clause "New" or "Revised" License
8.19k stars 1.4k forks source link

Batching and multi-commands for c# client #146

Open Ceyword opened 10 years ago

Ceyword commented 10 years ago

I ran a 100 loops of my business logic saving to SSDB and it took about 10 minutes. The same 100 loops saving to Redis took about 2 minutes. I could only attribute this big difference to the c# client. It does not yet support batching and multi-hset, multi-zset, multi-hget multi-zget e.t.c.. Can we have this commands added to the c# client? Thank you in advance.

ideawu commented 10 years ago

Hi, although the C# client does not have multi* functions, you can still invoke multi* commands to SSDB server. Use the flexible request functions of ssdb::Client class:

public List<byte[]> request(string cmd, params string[] args);
public List<byte[]> request(string cmd, params byte[][] args);
public List<byte[]> request(List<byte[]> req);

Example:

request("multi_set", "z", "a", "1", "b", "2")

This is equivalent to

zset("z", "a", "1");
zset("z", "b", "2");
Ceyword commented 10 years ago

I will use this principle to add multi-commands to the client. I still need the batch()-exec() command though! Thank you.