Redis:高性能key-value存储,持久化,支持string,list等多种数据类型,支持N多命令,相当灵活。
Demo:
windows版(非官方,开发调试用,Redis本身不支持Windows)
https://github.com/dmajkic/redis/
prebuilt binaries https://github.com/dmajkic/redis/downloads
下载解压后的文件:
libhiredis.dll
redis-benchmark.exe
redis-check-aof.exe
redis-check-dump.exe
redis-cli.exe
redis-server.exe
redis.conf
redis-server.exe是Redis服务程序,命令行运行后启动服务端
[2624] 28 May 17:19:30 * Server started, Redis version 2.4.2
[2624] 28 May 17:19:30 # Open data file dump.rdb: No such file or directory
[2624] 28 May 17:19:30 * The server is now ready to accept connections on port 6379
redis-cli.exe是一个客户端程序,命令行下运行,简单的一个Set/Get
redis 127.0.0.1:6379> set mykey "this is a value"
OK
redis 127.0.0.1:6379> get mykey
"this is a value"
redis 127.0.0.1:6379>
C#客户端
有好几个,本文使用ServiceStack.Redis
https://github.com/ServiceStack/ServiceStack.Redis
常用方法
RedisClient(string host, int port);
//set key value
bool Set<T>(string key, T value);
//get value
byte[] Get(string key);
//set list
AddItemToList(string listId, string value);
//get list
List<string> GetAllItemsFromList(string listId);
//set object<T>
bool Set<T>(string key, T value);
//get object<T>
T Get<T>(string key);
链接: