lawnchair 0.6.5 → 0.6.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.5
1
+ 0.6.6
data/lawnchair.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lawnchair}
8
- s.version = "0.6.5"
8
+ s.version = "0.6.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Shane Wolf"]
12
- s.date = %q{2010-08-09}
12
+ s.date = %q{2010-08-10}
13
13
  s.description = %q{Fully featured caching mechanism for arbitrary pieces of resource expensive ruby code using Redis while being able to optionally store data in the Ruby process itself for maximum efficiency.}
14
14
  s.email = %q{shanewolf@gmail.com}
15
15
  s.extra_rdoc_files = [
data/lib/lawnchair.rb CHANGED
@@ -26,7 +26,6 @@ module Lawnchair
26
26
 
27
27
  def connectdb(redis=nil)
28
28
  @redis = (redis || Redis.new(:db => 11))
29
- Lawnchair::StorageEngine::Redis.verify_db_connection
30
29
  end
31
30
 
32
31
  def flushdb
@@ -9,20 +9,16 @@ module Lawnchair
9
9
  end
10
10
 
11
11
  def fetch(key, options={}, &block)
12
- if self.db_connection?
13
- start_time = Time.now
14
- if exists?(key)
15
- value = get(key, options)
16
- log("HIT", key, Time.now-start_time)
17
- return value
18
- else
19
- value = block.call
20
- set(key, value, options)
21
- log("MISS", key, Time.now-start_time)
22
- return value
23
- end
12
+ start_time = Time.now
13
+ if exists?(key)
14
+ value = get(key, options)
15
+ log("HIT", key, Time.now-start_time)
16
+ return value
24
17
  else
25
- block.call
18
+ value = block.call
19
+ set(key, value, options)
20
+ log("MISS", key, Time.now-start_time)
21
+ return value
26
22
  end
27
23
  end
28
24
 
@@ -7,10 +7,6 @@ module Lawnchair
7
7
  def data_store
8
8
  @@data_store
9
9
  end
10
-
11
- def db_connection?
12
- true
13
- end
14
10
 
15
11
  def set(key, value, options={})
16
12
  if options[:raw]
@@ -2,8 +2,6 @@ module Lawnchair
2
2
  module StorageEngine
3
3
  class Redis < Abstract
4
4
  class << self
5
- attr_reader :db_connection
6
-
7
5
  def data_store
8
6
  Lawnchair.redis
9
7
  end
@@ -25,26 +23,6 @@ module Lawnchair
25
23
  data_store.del(computed_key(key))
26
24
  log("EXPIRATION", key, Time.now-start_time)
27
25
  end
28
-
29
- def connection_established!
30
- verify_db_connection
31
- end
32
-
33
- def db_connection?
34
- return @db_connection unless @db_connection.nil?
35
- verify_db_connection
36
- end
37
-
38
- def verify_db_connection
39
- begin
40
- data_store.info
41
- @db_connection = true
42
- rescue Exception => e
43
- @db_connection = false
44
- ensure
45
- return @db_connection
46
- end
47
- end
48
26
  end
49
27
  end
50
28
  end
@@ -58,10 +58,4 @@ describe "Lawnchair::StorageEngine::InProcessStore" do
58
58
  in_process_store.data_store["Lawnchair:sim"].should == "ba"
59
59
  end
60
60
  end
61
-
62
- describe "#db_connection?" do
63
- it "should return true" do
64
- in_process_store.should be_db_connection
65
- end
66
- end
67
61
  end
@@ -69,58 +69,4 @@ describe "Lawnchair::StorageEngine::RedisStore" do
69
69
  Lawnchair.redis["Lawnchair:sim"].should == "ba"
70
70
  end
71
71
  end
72
-
73
- describe "db_connection?" do
74
- before do
75
- redis_store.stub!(:verify_db_connection).and_return(true)
76
- end
77
-
78
- context "when db_connection has been set" do
79
- it "returns the value in db_connection" do
80
- redis_store.instance_variable_set("@db_connection", false)
81
- redis_store.db_connection?.should be_false
82
- end
83
- end
84
-
85
- context "when db_connection has NOT been set" do
86
- it "returns the result from verify_db_connection" do
87
- redis_store.instance_variable_set("@db_connection", nil)
88
- redis_store.db_connection?.should == redis_store.verify_db_connection
89
- end
90
- end
91
- end
92
-
93
- describe ".verify_db_connection" do
94
- context "when we have established a connection to redis-server" do
95
- it "should return true" do
96
- lambda {redis_store.data_store}.should_not raise_error
97
- redis_store.db_connection?.should be_true
98
- end
99
- end
100
-
101
- context "when we have NOT established a connection to redis-server" do
102
- before do
103
- data_store = mock(:data_store)
104
- data_store.stub!(:info).and_raise("BOOM!")
105
- redis_store.stub!(:data_store).and_return(data_store)
106
- end
107
-
108
- it "returns false" do
109
- redis_store.verify_db_connection
110
- redis_store.db_connection?.should be_false
111
- end
112
- end
113
- end
114
-
115
- describe ".connection_established!" do
116
- before do
117
- redis_store.instance_variable_set("@db_connection", nil)
118
- redis_store.db_connection.should be_nil
119
- end
120
-
121
- it "re-verifies the connection" do
122
- redis_store.connection_established!
123
- redis_store.db_connection.should be_true
124
- end
125
- end
126
72
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lawnchair
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 5
10
- version: 0.6.5
9
+ - 6
10
+ version: 0.6.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Shane Wolf
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-09 00:00:00 -07:00
18
+ date: 2010-08-10 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency