Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Padrino::Cache to support all features of underlying cache #836

Merged
merged 6 commits into from Apr 30, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions padrino-cache/lib/padrino-cache/store/redis.rb
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
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