Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:ngmoco/cache-money

  • Loading branch information...
commit 3deb47da33f2813a5b69ca3f2208dfbdbdfeef81 2 parents 5710213 + 6f92c3a
Ashley Martens ashleym1972 authored
Showing with 22 additions and 13 deletions.
  1. +16 −12 lib/cash/mock.rb
  2. +6 −1 spec/spec_helper.rb
28 lib/cash/mock.rb
View
@@ -20,7 +20,7 @@ def initialize(value, raw, ttl)
@value = Marshal.dump(value)
end
- if ttl.zero?
+ if ttl.nil? || ttl.zero?
@ttl = self.class.default_ttl
else
@ttl = ttl
@@ -68,18 +68,22 @@ def set(key, value, ttl = CacheEntry.default_ttl, raw = false)
end
def get(key, raw = false)
- log "< get #{key}"
- unless self.has_unexpired_key?(key)
- log('> END')
- return nil
- end
-
- log("> sending key #{key}")
- log('> END')
- if raw
- self[key].value
+ if key.is_a?(Array)
+ get_multi(*key)
else
- self[key].unmarshal
+ log "< get #{key}"
+ unless self.has_unexpired_key?(key)
+ log('> END')
+ return nil
+ end
+
+ log("> sending key #{key}")
+ log('> END')
+ if raw
+ self[key].value
+ else
+ self[key].unmarshal
+ end
end
end
7 spec/spec_helper.rb
View
@@ -29,7 +29,12 @@
require 'fakeredis'
$memcache = Cash::Adapter::Redis.new(FakeRedis::Redis.new(),
:default_ttl => 1.minute.to_i)
-
+ when 'mock'
+ # Test with Mock client
+ require 'cash/adapter/memcache_client'
+ require 'cash/mock'
+ $memcache = Cash::Adapter::MemcacheClient.new(Cash::Mock.new(),
+ :default_ttl => 1.minute.to_i)
else
require 'cash/adapter/memcached'
# Test with memcached client
Please sign in to comment.
Something went wrong with that request. Please try again.