2016-06-21 121 views

回答

0

如果您使用.NET的核心使用它的DB號,我創建了,你可以使用像一個包裝類這樣的:

var redisConnectionString = "{Your Redis Cache Connection String}"; 
var rest = new Restme(redisConnectionString); 

//get cache data (support Generic cast) 
var cacheResult = rest.Get("home:testKey"); 
var cacheResult2 = rest.Get<bool>("home:testKey2"); 
var cacheResult3 = rest.Get<ObjectType>("home:testKey3"); 

//set cache data 
rest.Post("home:testKey","value"); 
rest.Post<bool>("home:testKey2",true); 

它實際上是StackExchange.Redis的一個簡單的包裝,所以如果你想瞬移到多個數據庫,只需簡單地實例化多個Restm e()對象作爲單獨的變量,每個都包含不同的Redis數據庫連接。

源代碼用在github:https://github.com/oelite/RESTme