sprockets-cache-redis 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sprockets-cache-redis.gemspec
4
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,16 @@
1
+ Sprockets Redis Cache
2
+ ====================
3
+
4
+ A cache store for Sprockets which utilities Redis.
5
+
6
+ Usage
7
+ -----
8
+
9
+ require 'sprocket-cache-redis'
10
+ env = Sprockets::Environment.new
11
+ env.cache = Sprockets::Cache::RedisStore.new(redis, 'sprockets')
12
+ ...
13
+
14
+ Where the first argument is a Redis connection, and the other is a key_prefix.
15
+
16
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,26 @@
1
+ require 'digest/md5'
2
+
3
+ module Sprockets
4
+ module Cache
5
+ class RedisStore
6
+ def initialize(redis_conn, key_prefix = 'sprockets')
7
+ @redis = redis_conn
8
+ @key_prefix = key_prefix
9
+ end
10
+
11
+ def [](key)
12
+ data = @redis.get path_for(key)
13
+ Marshal.load data if data
14
+ end
15
+
16
+ def []=(key, value)
17
+ @redis.set path_for(key), Marshal.dump(value)
18
+ end
19
+
20
+ private
21
+ def path_for(key)
22
+ @key_prefix + ':' + ::Digest::MD5.hexdigest(key)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ module Sprockets
2
+ module Cache
3
+ module Redis
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require "sprockets-cache-redis/version"
2
+ require "sprockets-cache-redis/redis_store"
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "sprockets-cache-redis/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "sprockets-cache-redis"
7
+ s.version = Sprockets::Cache::Redis::VERSION
8
+ s.authors = ["Carl Hörberg"]
9
+ s.email = ["carl.hoerberg@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{A Redis cache store for Sprockets}
12
+ s.description = %q{}
13
+
14
+ s.rubyforge_project = "sprockets-cache-redis"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sprockets-cache-redis
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Carl Hörberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-09-10 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: ''
15
+ email:
16
+ - carl.hoerberg@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - README.markdown
24
+ - Rakefile
25
+ - lib/sprockets-cache-redis.rb
26
+ - lib/sprockets-cache-redis/redis_store.rb
27
+ - lib/sprockets-cache-redis/version.rb
28
+ - sprockets-cache-redis.gemspec
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project: sprockets-cache-redis
49
+ rubygems_version: 1.8.6
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: A Redis cache store for Sprockets
53
+ test_files: []