Skip to content

Commit

Permalink
Some documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
carlhoerberg committed Sep 10, 2011
1 parent b893847 commit fe11b56
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/sprockets-cache-redis/redis_store.rb
Expand Up @@ -2,17 +2,23 @@

module Sprockets
module Cache
# A simple Redis cache store.
#
# environment.cache = Sprockets::Cache::RedisStore.new($redis)
#
class RedisStore
def initialize(redis_conn, key_prefix = 'sprockets')
@redis = redis_conn
@key_prefix = key_prefix
end

# Lookup value in cache
def [](key)
data = @redis.get path_for(key)
Marshal.load data if data
end

# Save value to cache
def []=(key, value)
@redis.set path_for(key), Marshal.dump(value)
end
Expand Down

0 comments on commit fe11b56

Please sign in to comment.