Crystal client for Memcached using the text procotol.
Add this to your application's shard.yml
:
dependencies:
memcached:
github: kuende/memcached
version: ~> 0.2
require "memcached"
client = Memcached::Client.new("localhost", "11211")
client.set("foo", "bar") # sets key foo=bar
client.set("foo", "bar", ttl: 3) # set key foo=bar, expire after 3 seconds
client.get("foo") # gets key foo
client.get_multi(["foo", "other"]) => {"foo" => "bar", "other" => nil}
client.add("foo", "bar") # set foo=bar only if foo=nil
client.replace("foo", "bar") # set foo=bar only if foo!=nil
client.incr("counter") # increments counter by 1
client.incr("counter", 2) # increments counter by 2
client.decr("counter") # decrements counter by 1
client.decr("counter", 2) # decrements counter by 2
client.append("key", "foo") # appends value foo to key
client.prepend("key", "foo") # prepends value foo to key
client.delete("foo") # deletes key "foo"
client.flush # deletes all keys
- get
- get_multi
- set
- add
- replace
- delete
- flush
- append
- prepend
- increment
- decrement
- touch
- Fork it ( https://github.com/kuende/memcached/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request