@@ -2,10 +2,51 @@ package main
2
2
3
3
import (
4
4
"fmt"
5
-
6
- "github.com/bradfitz/gomemcache/memcache"
7
5
memcacheWithTag "github.com/dakimura/memctag/memcache"
6
+ "github.com/bradfitz/gomemcache/memcache"
8
7
)
8
+ // memcacheWithTag "github.com/dakimura/memctag/memcache"
9
+
10
+ //func main() {
11
+ // mc := memcacheWithTag.NewClient("127.0.0.1:11211")
12
+ //
13
+ // item := memcache.Item{Key: "1:message", Value: []byte("cache1")}
14
+ // item2 := memcache.Item{Key: "2:message", Value: []byte("cache2")}
15
+ // item3 := memcache.Item{Key: "3:message", Value: []byte("cache3")}
16
+ // item4 := memcache.Item{Key: "4:message", Value: []byte("cache4")}
17
+ // item5 := memcache.Item{Key: "5:message", Value: []byte("cache5")}
18
+ // item6 := memcache.Item{Key: "6:message", Value: []byte("cache6")}
19
+ // item7 := memcache.Item{Key: "7:message", Value: []byte("cache7")}
20
+ // item8 := memcache.Item{Key: "8:message", Value: []byte("cache8")}
21
+ // item9 := memcache.Item{Key: "9:message", Value: []byte("cache9")}
22
+ // item10 := memcache.Item{Key: "10:message", Value: []byte("cache10")}
23
+ //
24
+ // tags := []string{"1-tag"}
25
+ //
26
+ // mc.SetWithTags(&item, tags)
27
+ // mc.SetWithTags(&item2, tags)
28
+ // mc.SetWithTags(&item3, tags)
29
+ // mc.SetWithTags(&item4, tags)
30
+ // mc.SetWithTags(&item5, tags)
31
+ // mc.SetWithTags(&item6, tags)
32
+ // mc.SetWithTags(&item7, tags)
33
+ // mc.SetWithTags(&item8, tags)
34
+ // mc.SetWithTags(&item9, tags)
35
+ // mc.SetWithTags(&item10, tags)
36
+ //
37
+ // printCache(mc.GetWithTags("1:message", tags))
38
+ // printCache(mc.GetWithTags("2:message", tags))
39
+ // printCache(mc.GetWithTags("3:message", tags))
40
+ // printCache(mc.GetWithTags("4:message", tags))
41
+ // printCache(mc.GetWithTags("5:message", tags))
42
+ // printCache(mc.GetWithTags("6:message", tags))
43
+ // printCache(mc.GetWithTags("7:message", tags))
44
+ // printCache(mc.GetWithTags("8:message", tags))
45
+ // printCache(mc.GetWithTags("9:message", tags))
46
+ // printCache(mc.GetWithTags("10:message", tags))
47
+ //}
48
+
49
+
9
50
10
51
func main () {
11
52
mc := memcacheWithTag .NewClient ("127.0.0.1:11211" )
@@ -17,27 +58,24 @@ func main() {
17
58
item2 := memcache.Item {Key : "2:message" , Value : []byte ("cache2" )}
18
59
item3 := memcache.Item {Key : "3:message" , Value : []byte ("cache3" )}
19
60
20
- mc .SetWithTags (& item , tags )
21
- mc .SetWithTags (& item2 , tags )
22
- mc .SetWithTags (& item3 , tag )
61
+ mc .SetWithTags (& item , [] string { "1-tag" , "2-tag" } )
62
+ mc .SetWithTags (& item2 , [] string { "1-tag" , "2-tag" } )
63
+ mc .SetWithTags (& item3 , [] string { "1- tag" } )
23
64
24
- printCache (mc .GetWithTags ("1:message" , tags )) //"1-tag", "2-tag"
25
- printCache (mc .GetWithTags ("2:message" , tags )) //"1-tag", "2-tag"
26
- printCache (mc .GetWithTags ("3:message" , tag )) //"1-tag"
27
-
28
- fmt .Println ("-------" )
65
+ //fmt.Println("-------")
29
66
mc .Delete ("2-tag" )
30
67
31
68
printCache (mc .GetWithTags ("1:message" , tags )) //"1-tag", "2-tag"
32
69
printCache (mc .GetWithTags ("2:message" , tags )) //"1-tag", "2-tag"
33
70
printCache (mc .GetWithTags ("3:message" , tag )) //"1-tag"
34
71
35
- fmt .Println ("-------" )
72
+ //fmt.Println("-------")
73
+ //
74
+ //mc.Delete("3:message")
75
+ //printCache(mc.GetWithTags("3:message", tag))
76
+ }
36
77
37
- mc .Delete ("3:message" )
38
- printCache (mc .GetWithTags ("3:message" , tag ))
39
78
40
- }
41
79
42
80
func printCache (item * memcache.Item , err error ) {
43
81
if err != nil {
0 commit comments