Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matsumotory/mruby-memcached
libmemcached bindings by mruby
https://github.com/matsumotory/mruby-memcached
Last synced: about 2 months ago
JSON representation
libmemcached bindings by mruby
- Host: GitHub
- URL: https://github.com/matsumotory/mruby-memcached
- Owner: matsumotory
- License: other
- Created: 2014-03-11T08:19:06.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T11:04:35.000Z (almost 7 years ago)
- Last Synced: 2024-10-18T18:25:24.193Z (3 months ago)
- Language: C
- Size: 19.5 KB
- Stars: 8
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mruby-memcached [![Build Status](https://travis-ci.org/matsumoto-r/mruby-memcached.png?branch=master)](https://travis-ci.org/matsumoto-r/mruby-memcached)
[libmemcached](http://libmemcached.org/libMemcached.html) bindings by mruby.
## install by mrbgems
- add conf.gem line to `build_config.rb````ruby
MRuby::Build.new do |conf|# ... (snip) ...
conf.gem :git => 'https://github.com/matsumoto-r/mruby-memcached.git'
end
```
## example
#### Get/Set
```ruby
> 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
```ruby
# 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", 11213m.behavior_set Memcached::MEMCACHED_BEHAVIOR_BINARY_PROTOCOL
m.behavior_set Memcached::MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2m.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