Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (40 sloc) 1.52 kb
e1e68dbe » flyerhzm
2012-07-24 update README
1 # jruby-memcached
1dd7ea37 » flyerhzm
2012-07-18 Initial commit
2
e1e68dbe » flyerhzm
2012-07-24 update README
3 A jruby memcached gem which is compatible with evan's [memcached][0] gem
4
ad86b27d » flyerhzm
2012-07-24 update README
5 ## Install
6
7 gem install jruby-memcached
8
e1e68dbe » flyerhzm
2012-07-24 update README
9 ## Usage
10
11 Now, in Ruby, require the library and instantiate a Memcached object at
12 a global level:
13
14 require 'memcached'
15 $cache = Memcached.new("localhost:11211")
16
17 Now you can set things and get things:
18
19 value = 'hello'
20 $cache.set 'test', value
21 $cache.get 'test' #=> "hello"
22
23 You can set with an expiration timeout:
24
25 value = 'hello'
26 $cache.set 'test', value, 1
27 sleep(2)
28 $cache.get 'test' #=> raises Memcached::NotFound
29
30 You can get multiple values at once:
31
32 value = 'hello'
33 $cache.set 'test', value
34 $cache.set 'test2', value
35 $cache.get ['test', 'test2', 'missing']
36 #=> {"test" => "hello", "test2" => "hello"}
37
206ba174 » flyerhzm
2012-08-22 update README and CHANGELOG
38 You can set a counter and increment it. Note that you must initialize it
39 with an integer, encoded as an unmarshalled ASCII string:
40
41 $cache.increment 'counter' #=> 1
42 $cache.increment 'counter' #=> 2
43 $cache.get('counter').to_i #=> 2
44
45 You can get some server stats:
46
47 $cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
48
d313af4f » flyerhzm
2012-08-16 add Rails section in README
49 ## Rails
50
51 # config/environment.rb
52 config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])
53
e1e68dbe » flyerhzm
2012-07-24 update README
54 ## Benchmarks
55
58275c72 » flyerhzm
2012-07-24 update README
56 memcached.gem is the fastest memcached gem in MRI,
57 jruby-memcached is the fastest memcached gem in JRuby.
58 See [benchmark][1]
e1e68dbe » flyerhzm
2012-07-24 update README
59
d3f7f9a0 » flyerhzm
2012-08-07 update README
60 [0]: https://github.com/evan/memcached
61 [1]: https://github.com/aurorafeint/jruby-memcached/blob/master/benchmark.rb
Something went wrong with that request. Please try again.