如果需要簽署的元件,可以安裝StackExchange.Redis.StrongName這個套件

透過ConnectionMultiplexer這個類別來產生連線,並重覆使用
再透過GetDatabase來取得要IDatabase介面,就可以存取Redis了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | namespace ConsoleApplication1 { using System; using StackExchange.Redis; class Program { static void Main( string [] args) { ConnectionMultiplexer conn = ConnectionMultiplexer.Connect( "127.0.0.1:6379" ); IDatabase cache = conn.GetDatabase(); cache.StringSet( "key1" , "value1" ); string data = cache.StringGet( "key1" ); Console.WriteLine(data); } } } |
沒有留言:
張貼留言