コード例 #1
0
    public static void Main()
    {
        MyCache cache0 = new MyCache(), cache1 = new MyCache();
        string  someRandomKey = "key" + new Random().Next().ToString();

        ShowResult(cache0, cache1, someRandomKey, "Initially");
        cache0.Set(someRandomKey, Encoding.UTF8.GetBytes("hello"));
        Thread.Sleep(10);     // the pub/sub is fast, but not *instant*
        ShowResult(cache0, cache1, someRandomKey, "Write to 0");
        cache1.Set(someRandomKey, Encoding.UTF8.GetBytes("world"));
        Thread.Sleep(10);     // the pub/sub is fast, but not *instant*
        ShowResult(cache0, cache1, someRandomKey, "Write to 1");
    }