/usr/share/doc/libkyototycoon2/example/ktmemcex.rb is in kyototycoon-doc 0.9.56-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | require 'memcache'
host = "127.0.0.1:11211"
options = {
:timeout => 3600,
}
printf("connecting...\n")
cache = MemCache.new([host], options)
printf("count: %s\n", cache.stats[host]["curr_items"])
printf("flusing...\n")
cache.flush_all
printf("count: %s\n", cache.stats[host]["curr_items"])
printf("setting...\n")
(1..10).each do |i|
str = i.to_s
cache.set(str, str, 180, { :raw => true })
cache.add(str, str, 180, { :raw => true })
cache.replace(str, str, 180, { :raw => true })
end
printf("count: %s\n", cache.stats[host]["curr_items"])
printf("incrementing...\n")
(1..10).each do |i|
str = i.to_s
cache.incr(str, 10000)
cache.decr(str, 1000)
end
printf("count: %s\n", cache.stats[host]["curr_items"])
printf("getting...\n")
(1..10).each do |i|
str = i.to_s
value = cache.get(str, { :raw => true })
printf("get: %s: %s\n", str, value)
end
printf("count: %s\n", cache.stats[host]["curr_items"])
printf("removing...\n")
(1..10).each do |i|
str = i.to_s
cache.delete(str)
end
printf("count: %s\n", cache.stats[host]["curr_items"])
|