Skip to content

Commit

Permalink
Merge pull request padrino#836 from icco/redis-extension
Browse files Browse the repository at this point in the history
Expand Padrino::Cache to support all features of underlying cache
  • Loading branch information
DAddYE committed Apr 30, 2012
2 parents 9e34b16 + 54409cc commit 7832933
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions padrino-cache/lib/padrino-cache/store/redis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,20 @@ def delete(key)
def flush
@backend.flushdb
end

##
# Redis has a ton of powerful features (see: https://github.com/redis/redis-rb), which we
# can't use due to how strict the cache library is. This method catches all method calls and
# tries to pass them on the the redis gem.
#
# @api private
def method_missing(name, *args, &block)
if @backend.respond_to?(name)
@backend.send(name, *args, &block)
else
super
end
end
end # Redis
end # Store
end # Cache
Expand Down
7 changes: 7 additions & 0 deletions padrino-cache/test/test_stores.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def teardown
Padrino.cache.flush
end

eval <<-REDIS_TEST
should 'add a value to a list' do
Padrino.cache.lpush(@test_key, "test")
assert_equal "test", Padrino.cache.lpop(@test_key)
end
REDIS_TEST

eval COMMON_TESTS
end
rescue LoadError
Expand Down

0 comments on commit 7832933

Please sign in to comment.