Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

last fixes and gem

  • Loading branch information...
commit 01689c429d8c912c6e295980eb89c75eaf88a06f 1 parent ab15018
Marcos Piccinini authored
2  Rakefile
View
@@ -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"]
2  VERSION
View
@@ -1 +1 @@
-0.1.0
+0.1.1
31 benchmark/tokyo_store.rb
View
@@ -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 }}
@@ -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 = []
@@ -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__
4 lib/tokyo_store.rb
View
@@ -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
@@ -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:
16 spec/tokyo_store_rufus_spec.rb
View
@@ -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
49 tokyo_store.gemspec
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.