Skip to content

Commit

Permalink
last fixes and gem
Browse files Browse the repository at this point in the history
  • Loading branch information
nofxx committed Jul 2, 2009
1 parent ab15018 commit 01689c4
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 27 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -5,7 +5,7 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "tokyo_store"
gem.summary = %Q{TODO}
gem.summary = "Tokyo Tyrant rails session store"
gem.email = "x@nofxx.com"
gem.homepage = "http://github.com/nofxx/tokyo_store"
gem.authors = ["Marcos Piccinini"]
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.1.0
0.1.1
31 changes: 15 additions & 16 deletions benchmark/tokyo_store.rb
Expand Up @@ -15,27 +15,28 @@
G = M * 10
OBJ = { :small => P, :medium => M, :big => G}

#TODO: Cabinet & memcached C bindings
@tokyo = ActiveSupport::Cache.lookup_store :tokyo_store, "localhost:1978"
@memca = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:11211"
@memto = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost:1978"

# # # Read & Write
Benchmark.bmbm do |b|
Benchmark.bmbm do |b|
b.report("TokyoStore# P") { 10_000.times { |i| @tokyo.write i.to_s, P }}
b.report("MemCacheD # P") { 10_000.times { |i| @memca.write i.to_s, P }}
b.report("MemCacheT # P") { 10_000.times { |i| @memto.write i.to_s, P }}
# b.report("TokyoStore# M") { 10_000.times { |i| @tokyo.write i.to_s, M }}
# b.report("MemCacheD # M") { 10_000.times { |i| @memca.write i.to_s, M }}
# b.report("MemCacheT # M") { 10_000.times { |i| @memto.write i.to_s, M }}
# b.report("TokyoStore# G") { 10_000.times { |i| @tokyo.write i.to_s, G }}
# b.report("MemCacheD # G") { 10_000.times { |i| @memca.write i.to_s, G }}
# b.report("MemCacheT # G") { 10_000.times { |i| @memto.write i.to_s, G }}
# b.report("TokyoStore# OB") { 10_000.times { |i| @tokyo.write i.to_s, OBJ }}
# b.report("MemCacheD # OB") { 10_000.times { |i| @memca.write i.to_s, OBJ }}
# b.report("MemCacheT # OB") { 10_000.times { |i| @memto.write i.to_s, OBJ }}
# b.report("TokyoStore# R") { 10_000.times { |i| @tokyo.read i.to_s }}
# b.report("MemCacheD # R") { 10_000.times { |i| @memca.read i.to_s }}
# b.report("MemCacheT # R") { 10_000.times { |i| @memto.read i.to_s }}
b.report("TokyoStore# M") { 10_000.times { |i| @tokyo.write i.to_s, M }}
b.report("MemCacheD # M") { 10_000.times { |i| @memca.write i.to_s, M }}
b.report("MemCacheT # M") { 10_000.times { |i| @memto.write i.to_s, M }}
b.report("TokyoStore# G") { 10_000.times { |i| @tokyo.write i.to_s, G }}
b.report("MemCacheD # G") { 10_000.times { |i| @memca.write i.to_s, G }}
b.report("MemCacheT # G") { 10_000.times { |i| @memto.write i.to_s, G }}
b.report("TokyoStore# OB") { 10_000.times { |i| @tokyo.write i.to_s, OBJ }}
b.report("MemCacheD # OB") { 10_000.times { |i| @memca.write i.to_s, OBJ }}
b.report("MemCacheT # OB") { 10_000.times { |i| @memto.write i.to_s, OBJ }}
b.report("TokyoStore# R") { 10_000.times { |i| @tokyo.read i.to_s }}
b.report("MemCacheD # R") { 10_000.times { |i| @memca.read i.to_s }}
b.report("MemCacheT # R") { 10_000.times { |i| @memto.read i.to_s }}
b.report("TokyoStore# E") { 10_000.times { |i| @tokyo.exist? i.to_s }}
b.report("MemCacheD # E") { 10_000.times { |i| @memca.exist? i.to_s }}
b.report("MemCacheT # E") { 10_000.times { |i| @memto.exist? i.to_s }}
Expand All @@ -48,8 +49,7 @@
b.report("TokyoStore# -") { 10_000.times { |i| @tokyo.decrement i.to_s }}
b.report("MemCacheD # -") { 10_000.times { |i| @memca.decrement i.to_s }}
b.report("MemCacheT # -") { 10_000.times { |i| @memto.decrement i.to_s }}

end
end

puts
thr = []
Expand All @@ -63,7 +63,6 @@
b.report("MemTo # R") { 100.times { |j| thr << Thread.new { 100.times { |i| @memto.read "#{j}-#{i}"}}}; thr.each { |t| t.join }; thr = [] }
end


__END__


Expand Down
4 changes: 3 additions & 1 deletion lib/tokyo_store.rb
Expand Up @@ -59,7 +59,9 @@ def read(key, options = nil) # :nodoc:
# TODO: benchmark [key] vs .get(key)
super
return nil unless val = @data[key]

val = Marshal.load(val) unless raw?(options)

val
# if str = @data.get(key)
# Marshal.load str
Expand Down Expand Up @@ -95,7 +97,7 @@ def delete(key, options = nil) # :nodoc:

def exist?(key, options = nil) # :nodoc:
# Local cache is checked first?
!@data[key].nil?
!read(key, options).nil?
end

def increment(key, amount = 1) # :nodoc:
Expand Down
16 changes: 8 additions & 8 deletions spec/tokyo_store_rufus_spec.rb
Expand Up @@ -195,14 +195,14 @@
end
end

# it "test_local_cache_of_exist" do
# @cache.with_local_cache do
# @cache.write('foo', 'bar')
# @cache.instance_variable_set(:@data, nil)
# @data.clear # Clear remote cache
# @cache.exist?('foo').should be_true
# end
# end
it "test_local_cache_of_exist" do
@cache.with_local_cache do
@cache.write('foo', 'bar')
@cache.instance_variable_set(:@data, nil)
@data.clear # Clear remote cache
@cache.exist?('foo').should be_true
end
end

it "test_local_cache_of_increment" do
@cache.with_local_cache do
Expand Down
49 changes: 49 additions & 0 deletions tokyo_store.gemspec
@@ -0,0 +1,49 @@
# -*- encoding: utf-8 -*-

Gem::Specification.new do |s|
s.name = %q{tokyo_store}
s.version = "0.1.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Marcos Piccinini"]
s.date = %q{2009-07-02}
s.email = %q{x@nofxx.com}
s.extra_rdoc_files = [
"LICENSE",
"README.rdoc"
]
s.files = [
".document",
".gitignore",
"LICENSE",
"README.rdoc",
"Rakefile",
"VERSION",
"benchmark/tokyo_store.rb",
"lib/tokyo_store.rb",
"spec/spec_helper.rb",
"spec/tokyo_store_rufus_spec.rb",
"spec/tokyo_store_spec.rb",
"tokyo_store.gemspec"
]
s.homepage = %q{http://github.com/nofxx/tokyo_store}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.4}
s.summary = %q{Tokyo Tyrant rails session store}
s.test_files = [
"spec/tokyo_store_spec.rb",
"spec/spec_helper.rb",
"spec/tokyo_store_rufus_spec.rb"
]

if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3

if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
else
end
else
end
end

0 comments on commit 01689c4

Please sign in to comment.