Skip to content

Commit

Permalink
Document breaking API change, fixes #424
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jan 10, 2014
1 parent f5d9963 commit 57be77e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions History.md
Expand Up @@ -4,6 +4,8 @@ Dalli Changelog
2.7.0 2.7.0
========== ==========


- BREAKING CHANGE:
Dalli::Client#add and #replace now return a truthy value, not boolean true or false.
- Multithreading support with dalli\_store: - Multithreading support with dalli\_store:
Use :pool\_size to create a pool of shared, threadsafe Dalli clients in Rails: Use :pool\_size to create a pool of shared, threadsafe Dalli clients in Rails:
```ruby ```ruby
Expand Down
8 changes: 4 additions & 4 deletions lib/dalli/cas/client.rb
Expand Up @@ -33,7 +33,7 @@ def get_multi_cas(*keys)


## ##
# Set the key-value pair, verifying existing CAS. # Set the key-value pair, verifying existing CAS.
# Returns the resulting CAS value if succeeded, and false otherwise. # Returns the resulting CAS value if succeeded, and falsy otherwise.
def set_cas(key, value, cas, ttl=nil, options=nil) def set_cas(key, value, cas, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i ttl ||= @options[:expires_in].to_i
perform(:set, key, value, ttl, cas, options) perform(:set, key, value, ttl, cas, options)
Expand All @@ -42,17 +42,17 @@ def set_cas(key, value, cas, ttl=nil, options=nil)
## ##
# Conditionally add a key/value pair, verifying existing CAS, only if the # Conditionally add a key/value pair, verifying existing CAS, only if the
# key already exists on the server. Returns the new CAS value if the # key already exists on the server. Returns the new CAS value if the
# operation succeeded, or false otherwise. # operation succeeded, or falsy otherwise.
def replace_cas(key, value, cas, ttl=nil, options=nil) def replace_cas(key, value, cas, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i ttl ||= @options[:expires_in].to_i
perform(:replace, key, value, ttl, cas, options) perform(:replace, key, value, ttl, cas, options)
end end


# Delete a key/value pair, verifying existing CAS. # Delete a key/value pair, verifying existing CAS.
# Returns true if succeeded, and false otherwise. # Returns true if succeeded, and falsy otherwise.
def delete_cas(key, cas=0) def delete_cas(key, cas=0)
perform(:delete, key, cas) perform(:delete, key, cas)
end end


end end
end end
4 changes: 2 additions & 2 deletions lib/dalli/client.rb
Expand Up @@ -105,15 +105,15 @@ def set(key, value, ttl=nil, options=nil)


## ##
# Conditionally add a key/value pair, if the key does not already exist # Conditionally add a key/value pair, if the key does not already exist
# on the server. Returns true if the operation succeeded. # on the server. Returns truthy if the operation succeeded.
def add(key, value, ttl=nil, options=nil) def add(key, value, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i ttl ||= @options[:expires_in].to_i
perform(:add, key, value, ttl, options) perform(:add, key, value, ttl, options)
end end


## ##
# Conditionally add a key/value pair, only if the key already exists # Conditionally add a key/value pair, only if the key already exists
# on the server. Returns true if the operation succeeded. # on the server. Returns truthy if the operation succeeded.
def replace(key, value, ttl=nil, options=nil) def replace(key, value, ttl=nil, options=nil)
ttl ||= @options[:expires_in].to_i ttl ||= @options[:expires_in].to_i
perform(:replace, key, value, ttl, 0, options) perform(:replace, key, value, ttl, 0, options)
Expand Down

0 comments on commit 57be77e

Please sign in to comment.