lawnchair 0.6.9 → 0.6.10

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.9
1
+ 0.6.10
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.9"
8
+ s.version = "0.6.10"
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-10-08}
12
+ s.date = %q{2010-10-11}
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 = [
@@ -9,7 +9,6 @@ module Lawnchair
9
9
  end
10
10
 
11
11
  def fetch(key, options={}, &block)
12
-
13
12
  start_time = Time.now
14
13
  if value = get(key, options)
15
14
  log("HIT", key, Time.now-start_time)
@@ -43,6 +42,7 @@ module Lawnchair
43
42
  end
44
43
 
45
44
  def log(message, key, elapsed)
45
+ Lawnchair.redis.hincrby(message, computed_key(key), 1)
46
46
  ActionController::Base.logger.info("Lawnchair Cache: #{message} (%0.6f secs): #{key}" % elapsed) if defined? ::ActionController::Base
47
47
  end
48
48
  end
data/spec/speed.rb CHANGED
@@ -77,4 +77,23 @@ Benchmark.bm(7) do |x|
77
77
  Lawnchair::StorageEngine::Redis.exists?("redis_cache")
78
78
  end
79
79
  end
80
+ end
81
+
82
+ puts "*** Hash access vs. key access ***"
83
+
84
+ Lawnchair.redis.set("key_lookup", expensive_stuff.to_s)
85
+ Lawnchair.redis.hset("hash_lookup", "value", expensive_stuff.to_s)
86
+
87
+ Benchmark.bm(7) do |x|
88
+ x.report("key: \t\t") do
89
+ (1..n).each do |i|
90
+ Lawnchair.redis.get("key_lookup")
91
+ end
92
+ end
93
+
94
+ x.report("hash:\t\t") do
95
+ (1..n).each do |i|
96
+ Lawnchair.redis.hget("hash_lookup", "value")
97
+ end
98
+ end
80
99
  end
@@ -24,6 +24,12 @@ describe "Lawnchair::StorageEngine::Abstract" do
24
24
  value = abstract_store.fetch("sim", :raw => true) { "DOESNT MATTER" }
25
25
  value.should == "ba"
26
26
  end
27
+
28
+ it "increments the cache HIT count for this key" do
29
+ abstract_store.fetch("sim", :raw => true) { "DOESNT MATTER" }
30
+ abstract_store.fetch("sim", :raw => true) { "DOESNT MATTER" }
31
+ Lawnchair.redis.hget("HIT", "Lawnchair:sim").should == "2"
32
+ end
27
33
  end
28
34
 
29
35
  context "when key does not exist" do
@@ -42,6 +48,15 @@ describe "Lawnchair::StorageEngine::Abstract" do
42
48
  value = abstract_store.fetch("sim", :raw => true) { "ba" }
43
49
  abstract_store.data_store["Lawnchair:sim"].should == "ba"
44
50
  end
51
+
52
+ it "increments the cache MISS count for this key" do
53
+ abstract_store.fetch("sim", :raw => true) { "ba" }
54
+ abstract_store.data_store["Lawnchair:sim"] = nil
55
+ abstract_store.fetch("sim", :raw => true) { "ba" }
56
+ abstract_store.data_store["Lawnchair:sim"] = nil
57
+ abstract_store.fetch("sim", :raw => true) { "ba" }
58
+ Lawnchair.redis.hget("MISS", "Lawnchair:sim").should == "3"
59
+ end
45
60
  end
46
61
  end
47
62
 
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: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 9
10
- version: 0.6.9
9
+ - 10
10
+ version: 0.6.10
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-10-08 00:00:00 -07:00
18
+ date: 2010-10-11 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency