Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (40 sloc) 1.52 kb
e1e68db Richard Huang update README
flyerhzm authored
1 # jruby-memcached
1dd7ea3 Richard Huang Initial commit
flyerhzm authored
2
e1e68db Richard Huang update README
flyerhzm authored
3 A jruby memcached gem which is compatible with evan's [memcached][0] gem
4
ad86b27 Richard Huang update README
flyerhzm authored
5 ## Install
6
7 gem install jruby-memcached
8
e1e68db Richard Huang update README
flyerhzm authored
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
206ba17 Richard Huang update README and CHANGELOG
flyerhzm authored
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
d313af4 Richard Huang add Rails section in README
flyerhzm authored
49 ## Rails
50
51 # config/environment.rb
52 config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])
53
e1e68db Richard Huang update README
flyerhzm authored
54 ## Benchmarks
55
58275c7 Richard Huang update README
flyerhzm authored
56 memcached.gem is the fastest memcached gem in MRI,
57 jruby-memcached is the fastest memcached gem in JRuby.
58 See [benchmark][1]
e1e68db Richard Huang update README
flyerhzm authored
59
d3f7f9a Richard Huang update README
flyerhzm authored
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.