Skip to content

Instantly share code, notes, and snippets.

@halostatue
Last active August 29, 2015 14:14
Show Gist options
  • Save halostatue/2341fda222ec47a45f5b to your computer and use it in GitHub Desktop.
Save halostatue/2341fda222ec47a45f5b to your computer and use it in GitHub Desktop.
Demonstrate stockpile#2
require 'test_application'
# Turn off the default namespacing
TestApplication.cache(namespace: nil).connect
require 'stockpile-redis'
module TestApplication
Stockpile.inject_redis!(self)
module LastRunTime
def last_run_time(name, time = nil)
if time
connection.hset(__method__, name, time.8601)
else
time = connection.hget(__method__, name)
time = Time.parse(time) if time
end
time
end
end
cache_adapter(LastRunTime, self)
end

Actual Output

% redis-cli
127.0.0.1:6379> keys '*'
1) 'development:last_run_time'

Expected Output

% redis-cli
127.0.0.1:6379> keys '*'
1) 'last_run_time'
@halostatue
Copy link
Author

In Stockpile 1.0, line 18 initializes TestApplication.cache. This wouldn’t be a problem, except that we have an explicit setting of namespace, and this won’t be used—because the cache is being initialized before we set the namespace.

This has been fixed in Stockpile 1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment