-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathEnyimMemCached.linq
54 lines (40 loc) · 1.06 KB
/
EnyimMemCached.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<Query Kind="Program">
<NuGetReference>EnyimMemcached</NuGetReference>
<Namespace>Enyim.Caching</Namespace>
<Namespace>Enyim.Caching.Configuration</Namespace>
</Query>
void Main()
{
//The memcached docker image must be online.
//
//docker run --name fancy_image_pants -p 11211:11211 -d memcached memcached -m 64
MemcachedClientConfiguration config = new MemcachedClientConfiguration();
config.AddServer("127.0.0.1", 11211);
MemcachedClient client = new MemcachedClient(config);
string key = "Chicago";
var p = new Parent() { Name = "Jaxel", ParentId = 2};
var res = client.ExecuteStore(Enyim.Caching.Memcached.StoreMode.Set, key, p);
res.Dump();
var result = client.ExecuteTryGet(key, out object tmp);
result.Dump();
if (result.Success)
{
if (tmp is Parent)
{
tmp.GetType().Dump();
tmp.Dump();
}
}
var t = client.ExecuteRemove(key);
if (t.Success)
{
t.Dump("Removed");
}
}
// Define other methods and classes here
[Serializable]
public class Parent
{
public int ParentId { get; set; }
public string Name { get; set; }
}