ngmoco / cache-money

A Write-Through Cacheing Library for ActiveRecord
Apache License 2.0
161 stars 31 forks source link

Solved a bug with memcache_client.rb adapter #28

Closed eliasbaixas closed 12 years ago

eliasbaixas commented 12 years ago

a default value for ttl parameter was not being correctly provided in method memcache_client#add

def add(key, value, ttl=nil, raw=false) @repository.add(key, value || @default_ttl, ttl, raw)

recall that instead of doing || @default_ttl next to ttl, its done in value.

This caused an exception in memcache-client because not providing the TTL is a memcached network protocol error and memcaded returns ERROR.

thanks for this great work !!

Elias

ashleym1972 commented 12 years ago

Sorry dude, but I am not changing the name of the GEM.

eliasbaixas commented 12 years ago

I am sorry, I'm still not very used to this pull-request thing... maybe if I send you the patch you would want to take a look at it ?

the patch without the changes in version or Rackfile.

its just this:

diff --git a/lib/cash/adapter/memcache_client.rb b/lib/cash/adapter/memcache_client.rb index 5003c0c..0dc04a7 100644 --- a/lib/cash/adapter/memcache_client.rb +++ b/lib/cash/adapter/memcache_client.rb @@ -10,11 +10,11 @@ module Cash end

   def add(key, value, ttl=nil, raw=false)

and then

diff --git a/lib/cash/query/abstract.rb b/lib/cash/query/abstract.rb index bcba8fb..5730452 100644 --- a/lib/cash/query/abstract.rb +++ b/lib/cash/query/abstract.rb @@ -211,7 +211,14 @@ module Cash order_sql = @options1[:order] || @options2[:order] options[:order] = order_sql if order_sql results = find_from_ids_without_cache(missing_ids, options)

betamatt commented 12 years ago

@eliasbaixas the general deal with pull requests is to 1) create a feature branch for your change and 2) never touch the gemspec or any version information.

Make it painless for the maintainer to pull your change. Otherwise, while good intentioned and trying to be helpful, you end up creating work.

ashleym1972 commented 12 years ago

I made your changes to the files and pushed them up. I also published the new GEM.