padrino-cache 0.10.1 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -255,6 +255,7 @@ You can set a global caching option or a per app caching options.
255
255
 
256
256
  Padrino.cache = Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
257
257
  Padrino.cache = Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
258
+ Padrino.cache = Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new(...)
258
259
  Padrino.cache = Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
259
260
  Padrino.cache = Padrino::Cache::Store::Memory.new(50)
260
261
  Padrino.cache = Padrino::Cache::Store::File.new(/my/cache/path)
@@ -271,6 +272,7 @@ You can manage your cache from anywhere in your app:
271
272
  set :cache, Padrino::Cache::Store::Memcache.new(::Memcached.new('127.0.0.1:11211', :exception_retry_limit => 1))
272
273
  set :cache, Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
273
274
  set :cache, Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
275
+ set :cache, Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new(...))
274
276
  set :cache, Padrino::Cache::Store::Memory.new(50)
275
277
  set :cache, Padrino::Cache::Store::File.new(Padrino.root('tmp', app_name, 'cache') # default choice
276
278
 
@@ -1,7 +1,7 @@
1
1
  module Padrino
2
2
  module Cache
3
3
  module Helpers
4
- module CacheStore #:nodoc:
4
+ module CacheStore # @private
5
5
  def expire(*key)
6
6
  if key.size == 1 and key.first.is_a?(String)
7
7
  settings.cache.delete(key)
@@ -12,4 +12,4 @@ module Padrino
12
12
  end # CacheStore
13
13
  end # Helpers
14
14
  end # Cache
15
- end # Padrino
15
+ end # Padrino
@@ -57,4 +57,4 @@ module Padrino
57
57
  end # Fragment
58
58
  end # Helpers
59
59
  end # Cache
60
- end # Padrino
60
+ end # Padrino
@@ -54,7 +54,7 @@ module Padrino
54
54
  @_cache_key = name
55
55
  end
56
56
 
57
- def self.padrino_route_added(route, verb, path, args, options, block) #:nodoc:
57
+ def self.padrino_route_added(route, verb, path, args, options, block) # @private
58
58
  if route.cache and %w(GET HEAD).include?(verb)
59
59
  route.add_before_filter(Proc.new {
60
60
  if settings.caching?
@@ -83,4 +83,4 @@ module Padrino
83
83
  end # Page
84
84
  end # Helpers
85
85
  end # Cache
86
- end # Padrino
86
+ end # Padrino
@@ -96,4 +96,4 @@ module Padrino
96
96
  end # File
97
97
  end # Store
98
98
  end # Cache
99
- end # Padrino
99
+ end # Padrino
@@ -77,4 +77,4 @@ module Padrino
77
77
  end # Memcached
78
78
  end # Store
79
79
  end # Cache
80
- end # Padrino
80
+ end # Padrino
@@ -88,4 +88,4 @@ module Padrino
88
88
  end # Memory
89
89
  end # Store
90
90
  end # Cache
91
- end # Padrino
91
+ end # Padrino
@@ -73,4 +73,4 @@ module Padrino
73
73
  end # Redis
74
74
  end # Store
75
75
  end # Cache
76
- end # Padrino
76
+ end # Padrino
data/lib/padrino-cache.rb CHANGED
@@ -90,7 +90,7 @@ module Padrino
90
90
  end
91
91
  alias :included :registered
92
92
 
93
- def padrino_route_added(route, verb, path, args, options, block) #:nodoc
93
+ def padrino_route_added(route, verb, path, args, options, block) # @private
94
94
  Padrino::Cache::Helpers::Page.padrino_route_added(route, verb, path, args, options, block)
95
95
  end
96
96
  end
@@ -23,4 +23,4 @@ Gem::Specification.new do |s|
23
23
  s.rdoc_options = ["--charset=UTF-8"]
24
24
 
25
25
  s.add_runtime_dependency("padrino-core", Padrino.version)
26
- end
26
+ end
@@ -190,4 +190,4 @@ class TestPadrinoCache < Test::Unit::TestCase
190
190
  get "/foo"
191
191
  assert_equal 500, status
192
192
  end
193
- end
193
+ end
data/test/test_stores.rb CHANGED
@@ -5,37 +5,37 @@ class Foo
5
5
  end
6
6
 
7
7
  COMMON_TESTS = <<-HERE_DOC
8
+ should "return nil trying to get a value that doesn't exist" do
9
+ assert_equal nil, Padrino.cache.get(@test_key)
10
+ end
11
+
8
12
  should 'set and get an object' do
9
- Padrino.cache.set('val', Foo.new)
10
- assert_equal "bar", Padrino.cache.get('val').bar
13
+ Padrino.cache.set(@test_key, Foo.new)
14
+ assert_equal "bar", Padrino.cache.get(@test_key).bar
11
15
  end
12
16
 
13
17
  should 'set and get a nil value' do
14
- Padrino.cache.set('val', nil)
15
- assert_equal nil, Padrino.cache.get('val')
18
+ Padrino.cache.set(@test_key, nil)
19
+ assert_equal nil, Padrino.cache.get(@test_key)
16
20
  end
17
21
 
18
22
  should 'set and get a raw value' do
19
- Padrino.cache.set('val', 'foo')
20
- assert_equal 'foo', Padrino.cache.get('val')
21
- end
22
-
23
- should "return nil trying to get a value that doesn't exist" do
24
- assert_equal nil, Padrino.cache.get('test')
23
+ Padrino.cache.set(@test_key, 'foo')
24
+ assert_equal 'foo', Padrino.cache.get(@test_key)
25
25
  end
26
26
 
27
27
  should "set a value that expires" do
28
- Padrino.cache.set('val', 'test', :expires_in => 1)
29
- assert_equal 'test', Padrino.cache.get('val')
28
+ Padrino.cache.set(@test_key, 'test', :expires_in => 1)
29
+ # assert_equal 'test', Padrino.cache.get(@test_key) # Fails on race condition
30
30
  sleep 2
31
- assert_equal nil, Padrino.cache.get('val')
31
+ assert_equal nil, Padrino.cache.get(@test_key)
32
32
  end
33
33
 
34
34
  should 'delete a value' do
35
- Padrino.cache.set('val', 'test')
36
- assert_equal 'test', Padrino.cache.get('val')
37
- Padrino.cache.delete('val')
38
- assert_equal nil, Padrino.cache.get('val')
35
+ Padrino.cache.set(@test_key, 'test')
36
+ assert_equal 'test', Padrino.cache.get(@test_key)
37
+ Padrino.cache.delete(@test_key)
38
+ assert_equal nil, Padrino.cache.get(@test_key)
39
39
  end
40
40
  HERE_DOC
41
41
 
@@ -69,6 +69,7 @@ begin
69
69
  def setup
70
70
  Padrino.cache = Padrino::Cache::Store::Memcache.new(::Dalli::Client.new('127.0.0.1:11211', :exception_retry_limit => 1))
71
71
  Padrino.cache.flush
72
+ @test_key = "val_#{Time.now.to_i}"
72
73
  end
73
74
 
74
75
  def teardown
@@ -78,7 +79,7 @@ begin
78
79
  eval COMMON_TESTS
79
80
  end
80
81
  rescue LoadError
81
- warn "Skipping memcached with dalli library tests"
82
+ warn "Skipping memcache with dalli library tests"
82
83
  end
83
84
 
84
85
  begin
@@ -88,6 +89,7 @@ begin
88
89
  def setup
89
90
  Padrino.cache = Padrino::Cache::Store::Redis.new(::Redis.new(:host => '127.0.0.1', :port => 6379, :db => 0))
90
91
  Padrino.cache.flush
92
+ @test_key = "val_#{Time.now.to_i}"
91
93
  end
92
94
 
93
95
  def teardown
@@ -107,6 +109,7 @@ begin
107
109
  def setup
108
110
  Padrino.cache = Padrino::Cache::Store::Mongo.new(::Mongo::Connection.new('127.0.0.1', 27017).db('padrino-cache_test'), {:size => 10, :collection => 'cache'})
109
111
  Padrino.cache.flush
112
+ @test_key = "val_#{Time.now.to_i}"
110
113
  end
111
114
 
112
115
  def teardown
@@ -124,6 +127,7 @@ class TestFileStore < Test::Unit::TestCase
124
127
  @apptmp = "#{Dir.tmpdir}/padrino-tests/#{UUID.new.generate}"
125
128
  FileUtils.mkdir_p(@apptmp)
126
129
  Padrino.cache = Padrino::Cache::Store::File.new(@apptmp)
130
+ @test_key = "val_#{Time.now.to_i}"
127
131
  end
128
132
 
129
133
  def teardown
@@ -136,6 +140,7 @@ end
136
140
  class TestInMemoryStore < Test::Unit::TestCase
137
141
  def setup
138
142
  Padrino.cache = Padrino::Cache::Store::Memory.new(50)
143
+ @test_key = "val_#{Time.now.to_i}"
139
144
  end
140
145
 
141
146
  def teardown
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-cache
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 51
4
5
  prerelease:
5
- version: 0.10.1
6
+ segments:
7
+ - 0
8
+ - 10
9
+ - 2
10
+ version: 0.10.2
6
11
  platform: ruby
7
12
  authors:
8
13
  - Padrino Team
@@ -13,7 +18,7 @@ autorequire:
13
18
  bindir: bin
14
19
  cert_chain: []
15
20
 
16
- date: 2011-08-01 00:00:00 -07:00
21
+ date: 2011-08-31 00:00:00 -07:00
17
22
  default_executable:
18
23
  dependencies:
19
24
  - !ruby/object:Gem::Dependency
@@ -24,7 +29,12 @@ dependencies:
24
29
  requirements:
25
30
  - - "="
26
31
  - !ruby/object:Gem::Version
27
- version: 0.10.1
32
+ hash: 51
33
+ segments:
34
+ - 0
35
+ - 10
36
+ - 2
37
+ version: 0.10.2
28
38
  type: :runtime
29
39
  version_requirements: *id001
30
40
  description: Caching support for memcached, page and fragment
@@ -69,12 +79,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
79
  requirements:
70
80
  - - ">="
71
81
  - !ruby/object:Gem::Version
82
+ hash: 3
83
+ segments:
84
+ - 0
72
85
  version: "0"
73
86
  required_rubygems_version: !ruby/object:Gem::Requirement
74
87
  none: false
75
88
  requirements:
76
89
  - - ">="
77
90
  - !ruby/object:Gem::Version
91
+ hash: 23
92
+ segments:
93
+ - 1
94
+ - 3
95
+ - 6
78
96
  version: 1.3.6
79
97
  requirements: []
80
98