Skip to content

matsumotory/mruby-memcached

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mruby-memcached Build Status

libmemcached bindings by mruby.

install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :git => 'https://github.com/matsumoto-r/mruby-memcached.git'
end

example

Get/Set

> m = Memcached.new "127.0.0.1:11211"
> m.set "hoge", "1"
 => 0
# defaule expire time is 0 sec(inifinity)
# m.set :foo, 10, 0
# if you want expire time 1000 sec,
# m.set :foo, 10, 1000
> m.set :foo, 10
 => 0
> m.get "hoge"
 => "1"
> m.get :hoge
 => "1"
> m.get "foo"
 => "10"
> m.close

Replicas

# m = Memcached.new "127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213"
m = Memcached.new "127.0.0.1:11211"
m.server_add "127.0.0.1", 11212
m.server_add "127.0.0.1", 11213

m.behavior_set Memcached::MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
m.behavior_set Memcached::MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2

m.set :hoge, "foo"
p m.get :hoge # => foo
m.flush_buffers

# exec the following memcat commands after flush_buffers

m.close

memcat

$ memcat --servers=127.0.0.1:11211 hoge
foo

$ memcat --servers=127.0.0.1:11212 hoge
foo

$ memcat --servers=127.0.0.1:11213 hoge
foo

License

under the MIT License:

  • see LICENSE file

About

libmemcached bindings by mruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published