Skip to content

Commit

Permalink
Update the README about exceptions (arthurnn#196)
Browse files Browse the repository at this point in the history
Co-authored-by: Jean Boussier <[email protected]>
  • Loading branch information
casperisfine and byroot authored Apr 14, 2021
1 parent 2915fb9 commit f19f132
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 542 deletions.
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Now, in Ruby, require the library and instantiate a Memcached object at a
global level:

require 'memcached'
$cache = Memcached.new("localhost:11211")
$cache = Memcached::Client.new("localhost:11211")

Now you can set things and get things:

Expand All @@ -51,7 +51,7 @@ You can set with an expiration timeout:
value = 'hello'
$cache.set 'test', value, 1
sleep(2)
$cache.get 'test' #=> raises Memcached::NotFound
$cache.get 'test' #=> nil

You can get multiple values at once:

Expand All @@ -74,17 +74,6 @@ You can get some server stats:

$cache.stats #=> {..., :bytes_written=>[62], :version=>["1.2.4"] ...}

Note that the API is not the same as that of **Ruby-MemCache** or
**memcache-client**. In particular, `nil` is a valid record value.
Memcached#get does not return `nil` on failure, rather it raises
**Memcached::NotFound**. This is consistent with the behavior of memcached
itself. For example:

$cache.set 'test', nil
$cache.get 'test' #=> nil
$cache.delete 'test'
$cache.get 'test' #=> raises Memcached::NotFound

## Rails 3 and 4

Use [memcached_store gem](https://github.com/Shopify/memcached_store) to
Expand Down
7 changes: 2 additions & 5 deletions test/unit/client_get_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,8 @@ def test_get_multi_mixed_marshalling
#
# hits = 0
# 20.times do |i|
# begin
# read_cache.get "#{key}#{i}"
# hits += 1
# rescue Memcached::NotFound
# end
# read_cache.get "#{key}#{i}"
# hits += 1
# end
# end
#
Expand Down
Loading

0 comments on commit f19f132

Please sign in to comment.