padrino-cache 0.13.0.beta3 → 0.13.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: c6c70cf3724057ea09a38e40330a3e6d9fdb0a74
4
- data.tar.gz: e23483154a290ba0a5ec048c1d77d4e3ed5978f6
3
+ metadata.gz: 92b6075e03da6a8e35fd8be6441693de04c7da00
4
+ data.tar.gz: f55e79f9c81a099fbcc328deb7062ab4bd628594
5
5
  SHA512:
6
- metadata.gz: 21b4ad795f88207c9db9eccf3e105790225ef6aeb28e57a3bcb87176184ab77f7567c334f466ffa2342cb1aeb8f9cb2d65d87c49bdb82d86295c62af4aaf9c45
7
- data.tar.gz: fa086048e28aea9ec85a3c8e28c9b666a7b89928bb30bdf87312198810b9a067bd44fab536d676e29cbe2e60b6ea74c62e33bffe349f56bf5b4d65ddc9f894f1
6
+ metadata.gz: b28478cdeef99a6f6588761b78fe1290c742c6acfc58c2aad49f168f01105b98490fbbb5ec4fee580e4c95d56af4656da43176a78dd704810884a2adbf4fff2b
7
+ data.tar.gz: b4aebbb30cb9f06e3675c61740ef168919946c744a0d5787fb9c0ef9a6c683f9d043220861df3001e117428fa4c3178588a185dfe528b89cd8517bd97ae3b23e
@@ -5,7 +5,8 @@ module Padrino
5
5
  def cache_object(key, opts = {})
6
6
  if settings.caching?
7
7
  began_at = Time.now
8
- if value = settings.cache[key.to_s]
8
+ if settings.cache.key?(key.to_s)
9
+ value = settings.cache[key.to_s]
9
10
  logger.debug "GET Object", began_at, key.to_s if defined?(logger)
10
11
  else
11
12
  value = yield
@@ -51,9 +51,10 @@ module Padrino
51
51
  def cache(key, opts = {}, &block)
52
52
  if settings.caching?
53
53
  began_at = Time.now
54
- if value = settings.cache[key.to_s]
54
+ if settings.cache.key?(key.to_s)
55
+ value = settings.cache[key.to_s]
55
56
  logger.debug "GET Fragment", began_at, key.to_s if defined?(logger)
56
- concat_content(value.html_safe)
57
+ concat_content(value.to_s.html_safe)
57
58
  else
58
59
  value = capture_html(&block)
59
60
  settings.cache.store(key.to_s, value, opts)
@@ -479,4 +479,31 @@ describe "PadrinoCache" do
479
479
  end
480
480
  assert_kind_of Moneta::Adapters::Memory, adapter
481
481
  end
482
+
483
+ it "should check key existence" do
484
+ count1, count2 = 0, 0
485
+ mock_app do
486
+ register Padrino::Cache
487
+ enable :caching
488
+ get "/" do
489
+ cache(:foo) do
490
+ count1 += 1
491
+ nil
492
+ end
493
+ count1.inspect
494
+ end
495
+
496
+ get "/object" do
497
+ cache_object(:bar) do
498
+ count2 += 1
499
+ nil
500
+ end
501
+ count2.inspect
502
+ end
503
+ end
504
+ 2.times { get "/" }
505
+ assert_equal "1", body
506
+ 2.times { get "/object" }
507
+ assert_equal "1", body
508
+ end
482
509
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0.beta3
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-08-02 00:00:00.000000000 Z
14
+ date: 2015-10-11 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: padrino-core
@@ -19,28 +19,28 @@ dependencies:
19
19
  requirements:
20
20
  - - '='
21
21
  - !ruby/object:Gem::Version
22
- version: 0.13.0.beta3
22
+ version: 0.13.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - '='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.13.0.beta3
29
+ version: 0.13.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: padrino-helpers
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - '='
35
35
  - !ruby/object:Gem::Version
36
- version: 0.13.0.beta3
36
+ version: 0.13.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - '='
42
42
  - !ruby/object:Gem::Version
43
- version: 0.13.0.beta3
43
+ version: 0.13.0
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: moneta
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -93,12 +93,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>'
96
+ - - '>='
97
97
  - !ruby/object:Gem::Version
98
- version: 1.3.1
98
+ version: 1.3.6
99
99
  requirements: []
100
100
  rubyforge_project: padrino-cache
101
- rubygems_version: 2.0.6
101
+ rubygems_version: 2.4.8
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Page and fragment caching for Padrino