Skip to content

kuende/memcached

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memcached

Build Status

Crystal client for Memcached using the text procotol.

Installation

Add this to your application's shard.yml:

dependencies:
  memcached:
    github: kuende/memcached
    version: ~> 0.2

Usage

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

Implemented

  • get
  • get_multi
  • set
  • add
  • replace
  • delete
  • flush
  • append
  • prepend
  • increment
  • decrement
  • touch

Contributing

  1. Fork it ( https://github.com/kuende/memcached/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Memcached client for Crystal

Resources

License

Stars

Watchers

Forks

Packages

No packages published