Permalink
Browse files

Merge pull request #5 from phlipper/patch-1

add GitHub Flavored Markdown to README
  • Loading branch information...
flyerhzm committed Dec 14, 2012
2 parents 9ddf418 + 2144eed commit 292d613a958947e142207ca22fd824d4a5dd7324
Showing with 34 additions and 20 deletions.
  1. +34 −20 README.md
View
@@ -11,45 +11,59 @@ A jruby memcached gem which is compatible with evan's [memcached][0] gem
Now, in Ruby, require the library and instantiate a Memcached object at
a global level:
- require 'memcached'
- $cache = Memcached.new("localhost:11211")
+```ruby
+require 'memcached'
+$cache = Memcached.new("localhost:11211")
+```
Now you can set things and get things:
- value = 'hello'
- $cache.set 'test', value
- $cache.get 'test' #=> "hello"
+```ruby
+value = 'hello'
+$cache.set 'test', value
+$cache.get 'test' #=> "hello"
+```
You can set with an expiration timeout:
- value = 'hello'
- $cache.set 'test', value, 1
- sleep(2)
- $cache.get 'test' #=> raises Memcached::NotFound
+```ruby
+value = 'hello'
+$cache.set 'test', value, 1
+sleep(2)
+$cache.get 'test' #=> raises Memcached::NotFound
+```
You can get multiple values at once:
- value = 'hello'
- $cache.set 'test', value
- $cache.set 'test2', value
- $cache.get ['test', 'test2', 'missing']
- #=> {"test" => "hello", "test2" => "hello"}
+```ruby
+value = 'hello'
+$cache.set 'test', value
+$cache.set 'test2', value
+$cache.get ['test', 'test2', 'missing']
+ #=> {"test" => "hello", "test2" => "hello"}
+```
You can set a counter and increment it. Note that you must initialize it
with an integer, encoded as an unmarshalled ASCII string:
- $cache.increment 'counter' #=> 1
- $cache.increment 'counter' #=> 2
- $cache.get('counter').to_i #=> 2
+```ruby
+$cache.increment 'counter' #=> 1
+$cache.increment 'counter' #=> 2
+$cache.get('counter').to_i #=> 2
+```
You can get some server stats:
- $cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
+```ruby
+$cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}
+```
## Rails
- # config/environment.rb
- config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])
+```ruby
+# config/environment.rb
+config.cache_store = Memcached::Rails.new(:servers => ['127.0.0.1'])
+```
## Benchmarks

0 comments on commit 292d613

Please sign in to comment.