redis-activesupport 3.2.5 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3eaefc22106ae1fb72c5baa4b8a14aea25ebbf0c
4
- data.tar.gz: f85b25581b838bdf3dfd6ab98f9910b904a5ffef
3
+ metadata.gz: e812b725218799448b4fccf029a6e3f45e9dd9a5
4
+ data.tar.gz: 997c46b3aebb292245a7c1f2f1353907b5de70c3
5
5
  SHA512:
6
- metadata.gz: 83f7046c4a83e15c06c50a4792b0d525f8c33600121e3012bd5b699fcad6cf60fc57f7da503913b038bbbc4f9bfd688981d00fb21b00a6d68ff2347588b39b77
7
- data.tar.gz: 78b1e52ca36d2e61da96b579a898f7e17bd259bf0d8f01dad84e846a34d61ffbd367a4014108b7673effc20f5a45e62a9b6da55056c819db3e721e8d490c5911
6
+ metadata.gz: 50f9ebe7469531e877506c2c0319f4f6510d0f5e039098d4fa93ebf318d8b2de9cc9cc71acf0582fe5d9fc361443a591cf17ff3d2071ffbf02ee40c3c3115cd5
7
+ data.tar.gz: 20fa18aa279d0fcba4633c09e61af83966e15be4c8d7cf356d43bccb7f81ca8f1870a2d1a324c596a53f3d3c9dafebbc8d55f77194e94a7311380e1a1ed8a9e7
data/.gitignore CHANGED
@@ -1,3 +1,5 @@
1
- Gemfile.lock
2
1
  *.gem
3
- tmp/
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp/*
data/Gemfile CHANGED
@@ -1,8 +1,16 @@
1
1
  source 'https://rubygems.org'
2
2
  gemspec
3
3
 
4
- if ::File.directory?(gem_path = '../redis-store')
5
- gem 'redis-store', '~> 1.1.0', path: gem_path
4
+ gem 'redis-store', '~> 1.1.0', path: '../redis-store'
5
+ gem 'i18n'
6
+
7
+ version = ENV["RAILS_VERSION"] || "4"
8
+
9
+ rails = case version
10
+ when "master"
11
+ {:github => "rails/rails"}
12
+ else
13
+ "~> #{version}.0"
6
14
  end
7
15
 
8
- gem 'i18n'
16
+ gem "rails", rails
data/README.md CHANGED
@@ -1,39 +1,28 @@
1
1
  # Redis stores for ActiveSupport
2
2
 
3
- __`redis-activesupport`__ provides a cache for __ActiveSupport__. See the main [redis-store readme](https://github.com/redis-store/redis-store) for general guidelines.
3
+ __`redis-activesupport`__ provides a cache for __ActiveSupport__. See the main [redis-store readme](https://github.com/jodosha/redis-store) for general guidelines.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```ruby
8
- # Gemfile
9
- gem 'redis-activesupport'
10
- ```
7
+ # Gemfile
8
+ gem 'redis-activesupport'
11
9
 
12
- ## Usage
10
+ ### Usage
13
11
 
14
- If you are using redis-store with Rails, consider using the [redis-rails gem](https://github.com/redis-store/redis-rails) instead. For standalone usage:
12
+ If you are using redis-store with Rails, consider using the [redis-rails gem](https://github.com/jodosha/redis-store/tree/master/redis-rails) instead. For standalone usage:
15
13
 
16
- ```ruby
17
- ActiveSupport::Cache.lookup_store :redis_store # { ... optional configuration ... }
18
- ```
14
+ ActiveSupport::Cache.lookup_store :redis_store # { ... optional configuration ... }
19
15
 
20
16
  ## Running tests
21
17
 
22
- ```shell
23
- gem install bundler
24
- git clone git://github.com/redis-store/redis-activesupport.git
25
- cd redis-activesupport
26
- git checkout -t origin/3.2.x
27
- bundle install
28
- bundle exec rake
29
- ```
18
+ gem install bundler
19
+ git clone git://github.com/jodosha/redis-store.git
20
+ cd redis-store/redis-activesupport
21
+ bundle install
22
+ bundle exec rake
30
23
 
31
24
  If you are on **Snow Leopard** you have to run `env ARCHFLAGS="-arch x86_64" bundle exec rake`
32
25
 
33
- ## Status
34
-
35
- [![Gem Version](https://badge.fury.io/rb/redis-activesupport.png)](http://badge.fury.io/rb/redis-activesupport) [![Build Status](https://secure.travis-ci.org/redis-store/redis-activesupport.png?branch=3.2.x)](http://travis-ci.org/jodosha/redis-activesupport?branch=3.2.x) [![Code Climate](https://codeclimate.com/github/jodosha/redis-store.png)](https://codeclimate.com/github/redis-store/redis-activesupport)
36
-
37
26
  ## Copyright
38
27
 
39
- 2009 - 2013 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
28
+ (c) 2009 - 2011 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
data/Rakefile CHANGED
@@ -1,4 +1,8 @@
1
- require 'bundler/setup'
1
+ require 'bundler'
2
+ Bundler.setup
2
3
  require 'rake'
3
4
  require 'bundler/gem_tasks'
4
- require 'redis-store/testing/tasks'
5
+
6
+ load 'tasks/redis.tasks.rb'
7
+ task :default => 'redis:test:suite'
8
+
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'redis-store'
2
3
 
3
4
  module ActiveSupport
@@ -38,6 +39,11 @@ module ActiveSupport
38
39
 
39
40
  # Delete objects for matched keys.
40
41
  #
42
+ # Performance note: this operation can be dangerous for large production
43
+ # databases, as it uses the Redis "KEYS" command, which is O(N) over the
44
+ # total number of keys in the database. Users of large Redis caches should
45
+ # avoid this method.
46
+ #
41
47
  # Example:
42
48
  # cache.del_matched "rab*"
43
49
  def delete_matched(matcher, options = nil)
@@ -46,7 +52,7 @@ module ActiveSupport
46
52
  matcher = key_matcher(matcher, options)
47
53
  begin
48
54
  !(keys = @data.keys(matcher)).empty? && @data.del(*keys)
49
- rescue Errno::ECONNREFUSED
55
+ rescue Errno::ECONNREFUSED => e
50
56
  false
51
57
  end
52
58
  end
@@ -124,6 +130,10 @@ module ActiveSupport
124
130
  end
125
131
  end
126
132
 
133
+ def expire(key, ttl)
134
+ @data.expire key, ttl
135
+ end
136
+
127
137
  # Clear all the data from the store.
128
138
  def clear
129
139
  instrument(:clear, nil, nil) do
@@ -131,6 +141,13 @@ module ActiveSupport
131
141
  end
132
142
  end
133
143
 
144
+ # fixed problem with invalid exists? method
145
+ # https://github.com/rails/rails/commit/cad2c8f5791d5bd4af0f240d96e00bae76eabd2f
146
+ def exist?(name, options = nil)
147
+ res = super(name, options)
148
+ res || false
149
+ end
150
+
134
151
  def stats
135
152
  @data.info
136
153
  end
@@ -1,5 +1,5 @@
1
1
  class Redis
2
2
  module ActiveSupport
3
- VERSION = '3.2.5'
3
+ VERSION = '4.0.0'
4
4
  end
5
5
  end
@@ -1,31 +1,29 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path('../lib', __FILE__)
3
- require 'redis/activesupport/version'
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "redis/activesupport/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
- s.name = 'redis-activesupport'
6
+ s.name = "redis-activesupport"
7
7
  s.version = Redis::ActiveSupport::VERSION
8
- s.authors = ['Luca Guidi']
9
- s.email = ['me@lucaguidi.com']
10
- s.homepage = 'http://redis-store.org/redis-activesupport'
11
- s.summary = %q{Redis store for ActiveSupport}
12
- s.description = %q{Redis store for ActiveSupport}
13
- s.license = 'MIT'
8
+ s.authors = ["Luca Guidi"]
9
+ s.email = ["me@lucaguidi.com"]
10
+ s.homepage = "http://redis-store.org/redis-activesupport"
11
+ s.summary = %q{Redis store for ActiveSupport::Cache}
12
+ s.description = %q{Redis store for ActiveSupport::Cache}
14
13
 
15
- s.rubyforge_project = 'redis-activesupport'
14
+ s.rubyforge_project = "redis-activesupport"
16
15
 
17
16
  s.files = `git ls-files`.split("\n")
18
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
- s.require_paths = ['lib']
19
+ s.require_paths = ["lib"]
21
20
 
22
21
  s.add_runtime_dependency 'redis-store', '~> 1.1.0'
23
- s.add_runtime_dependency 'activesupport', '~> 3.2.0'
22
+ s.add_runtime_dependency 'activesupport', '~> 4'
24
23
 
25
24
  s.add_development_dependency 'rake', '~> 10'
26
25
  s.add_development_dependency 'bundler', '~> 1.3'
27
26
  s.add_development_dependency 'mocha', '~> 0.14.0'
28
27
  s.add_development_dependency 'minitest', '~> 4.2'
29
- s.add_development_dependency 'redis-store-testing'
30
28
  end
31
29
 
@@ -30,12 +30,32 @@ describe ActiveSupport::Cache::RedisStore do
30
30
  it "writes the data with expiration time" do
31
31
  with_store_management do |store|
32
32
  store.write "rabbit", @white_rabbit, :expires_in => 1.second
33
- # store.read("rabbit").must_equal(@white_rabbit)
33
+ store.read("rabbit").must_equal(@white_rabbit)
34
+ sleep 2
35
+ store.read("rabbit").must_be_nil
36
+ end
37
+ end
38
+
39
+ it "respects expiration time in seconds" do
40
+ with_store_management do |store|
41
+ store.write "rabbit", @white_rabbit
42
+ store.read("rabbit").must_equal(@white_rabbit)
43
+ store.expire "rabbit", 1.seconds
34
44
  sleep 2
35
45
  store.read("rabbit").must_be_nil
36
46
  end
37
47
  end
38
48
 
49
+ it "respects expiration time in minutes" do
50
+ with_store_management do |store|
51
+ store.write "rabbit", @white_rabbit
52
+ store.read("rabbit").must_equal(@white_rabbit)
53
+ store.expire "rabbit", 1.minutes
54
+ sleep 61
55
+ store.read("rabbit").must_be_nil
56
+ end
57
+ end
58
+
39
59
  it "does't write data if :unless_exist option is true" do
40
60
  with_store_management do |store|
41
61
  store.write "rabbit", @white_rabbit, :unless_exist => true
@@ -43,11 +63,21 @@ describe ActiveSupport::Cache::RedisStore do
43
63
  end
44
64
  end
45
65
 
46
- it "reads raw data" do
47
- with_store_management do |store|
48
- result = store.read("rabbit", :raw => true)
49
- result.must_include("ActiveSupport::Cache::Entry")
50
- result.must_match("bunny")
66
+ if RUBY_VERSION.match /1\.9/
67
+ it "reads raw data" do
68
+ with_store_management do |store|
69
+ result = store.read("rabbit", :raw => true)
70
+ result.must_include("ActiveSupport::Cache::Entry")
71
+ result.must_include("\x0FOpenStruct{\x06:\tnameI\"\nbunny\x06:\x06EF")
72
+ end
73
+ end
74
+ else
75
+ it "reads raw data" do
76
+ with_store_management do |store|
77
+ result = store.read("rabbit", :raw => true)
78
+ result.must_include("ActiveSupport::Cache::Entry")
79
+ result.must_include("\017OpenStruct{\006:\tname")
80
+ end
51
81
  end
52
82
  end
53
83
 
@@ -2,6 +2,6 @@ require 'test_helper'
2
2
 
3
3
  describe Redis::ActiveSupport::VERSION do
4
4
  it 'returns current version' do
5
- Redis::ActiveSupport::VERSION.must_equal '3.2.5'
5
+ Redis::ActiveSupport::VERSION.must_equal '4.0.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.5
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-store
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.0
33
+ version: '4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.0
40
+ version: '4'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -94,21 +94,7 @@ dependencies:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
96
  version: '4.2'
97
- - !ruby/object:Gem::Dependency
98
- name: redis-store-testing
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - '>='
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- description: Redis store for ActiveSupport
97
+ description: Redis store for ActiveSupport::Cache
112
98
  email:
113
99
  - me@lucaguidi.com
114
100
  executables: []
@@ -116,7 +102,6 @@ extensions: []
116
102
  extra_rdoc_files: []
117
103
  files:
118
104
  - .gitignore
119
- - .travis.yml
120
105
  - Gemfile
121
106
  - MIT-LICENSE
122
107
  - README.md
@@ -129,8 +114,7 @@ files:
129
114
  - test/redis/activesupport/version_test.rb
130
115
  - test/test_helper.rb
131
116
  homepage: http://redis-store.org/redis-activesupport
132
- licenses:
133
- - MIT
117
+ licenses: []
134
118
  metadata: {}
135
119
  post_install_message:
136
120
  rdoc_options: []
@@ -151,7 +135,7 @@ rubyforge_project: redis-activesupport
151
135
  rubygems_version: 2.0.3
152
136
  signing_key:
153
137
  specification_version: 4
154
- summary: Redis store for ActiveSupport
138
+ summary: Redis store for ActiveSupport::Cache
155
139
  test_files:
156
140
  - test/active_support/cache/redis_store_test.rb
157
141
  - test/redis/activesupport/version_test.rb
@@ -1,14 +0,0 @@
1
- language: ruby
2
- script: 'bundle exec rake'
3
- rvm:
4
- - 1.9.3
5
- - 2.0.0
6
- - ruby-head
7
- - rbx-19mode
8
- - jruby-19mode
9
- - jruby-head
10
-
11
- matrix:
12
- allow_failures:
13
- - rvm: jruby-head
14
- - rvm: ruby-head