dim-tokyo-cache-store 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README +42 -0
- data/Rakefile +27 -0
- data/VERSION +1 -0
- data/init.rb +1 -0
- data/lib/active_support/cache/tokyo_store.rb +53 -0
- data/pkg/.gitignore +1 -0
- data/spec/tokyo_cache_store_spec.rb +65 -0
- data/tmp/.gitignore +1 -0
- data/tokyo-cache-store.gemspec +54 -0
- metadata +82 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Dimitrij Denissenko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Tokyo Cache Store
|
2
|
+
=================
|
3
|
+
|
4
|
+
An ActiveSupport (Rails) cache-store plugin for Tokyo Tyrant.
|
5
|
+
|
6
|
+
Overview
|
7
|
+
|
8
|
+
* File based cache engine
|
9
|
+
* Lightning fast - performance comparable to memcached
|
10
|
+
http://www.mikeperham.com/2009/03/08/tokyo-cabinet-vs-memcached/
|
11
|
+
* High compression rates
|
12
|
+
* Excellent replication capabilities
|
13
|
+
|
14
|
+
Requirements
|
15
|
+
|
16
|
+
Tokyo Cabinet:
|
17
|
+
http://1978th.net/tokyocabinet/
|
18
|
+
|
19
|
+
Tokyo Tyrant:
|
20
|
+
http://1978th.net/tokyotyrant/
|
21
|
+
|
22
|
+
(Fast) Ruby Bindings:
|
23
|
+
sudo gem install actsasflinn-ruby-tokyotyrant --source=http://gems.github.com
|
24
|
+
|
25
|
+
Installation
|
26
|
+
|
27
|
+
As a rails plugin:
|
28
|
+
script/plugin install git://github.com/dim/tokyo-cache-store.git
|
29
|
+
|
30
|
+
As a GEM:
|
31
|
+
sudo gem install dim-tokyo-cache-store --source=http://gems.github.com
|
32
|
+
|
33
|
+
Usage (simplified)
|
34
|
+
|
35
|
+
Create a new cache store:
|
36
|
+
tchmgr create ./tmp/cache/tt_store.tch # See 'man tchmgr' for a full list of options
|
37
|
+
|
38
|
+
Start the tokyo-tyrant server:
|
39
|
+
ttserver ./tmp/cache/tt_store.tch # See 'man ttserver' for a full list of options
|
40
|
+
|
41
|
+
Configure the Rails cache store (in environment.rb):
|
42
|
+
config.cache_store = :tokyo_cache_store, 'localhost', 1978
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
desc "Run the extension specs"
|
7
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
8
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |spec|
|
14
|
+
spec.name = "tokyo-cache-store"
|
15
|
+
spec.summary = "Tokyo Tyrant Cache Store"
|
16
|
+
spec.email = "contact@dvisionfactory.com"
|
17
|
+
spec.homepage = "http://github.com/dim/tokyo-cache-store"
|
18
|
+
spec.description = "Tokyo Tyrant cache store for ActiveSupport/Rails."
|
19
|
+
spec.authors = ["Dimitrij Denissenko"]
|
20
|
+
spec.test_files = Dir.glob('spec/**')
|
21
|
+
spec.add_dependency('activesupport', '>= 2.3.0')
|
22
|
+
spec.add_dependency('actsasflinn-ruby-tokyotyrant', '>= 0.2.0')
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
26
|
+
end
|
27
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'active_support/cache/tokyo_store'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
gem 'actsasflinn-ruby-tokyotyrant', '>= 0.2.0'
|
2
|
+
require 'tokyo_tyrant'
|
3
|
+
|
4
|
+
module ActiveSupport
|
5
|
+
module Cache
|
6
|
+
class TokyoStore < Store
|
7
|
+
|
8
|
+
def initialize(host = 'localhost', port = 1978)
|
9
|
+
super()
|
10
|
+
@data = ::TokyoTyrant::DB.new(host, port)
|
11
|
+
end
|
12
|
+
|
13
|
+
def read(key, options = nil)
|
14
|
+
super
|
15
|
+
@data[key]
|
16
|
+
rescue TokyoTyrantError
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def write(key, value, options = nil)
|
21
|
+
super
|
22
|
+
@data[key] = value
|
23
|
+
rescue TokyoTyrantError
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def delete(key, options = nil)
|
28
|
+
super
|
29
|
+
@data.delete(key)
|
30
|
+
end
|
31
|
+
|
32
|
+
def delete_matched(matcher, options = nil)
|
33
|
+
super
|
34
|
+
@data.each_key { |k| @data.delete(k) if k =~ matcher }
|
35
|
+
end
|
36
|
+
|
37
|
+
def exist?(key, options = nil)
|
38
|
+
super
|
39
|
+
@data.key?(key)
|
40
|
+
end
|
41
|
+
|
42
|
+
def clear
|
43
|
+
log("clear", @data.keys.size, nil)
|
44
|
+
@data.clear
|
45
|
+
end
|
46
|
+
|
47
|
+
def keys
|
48
|
+
@data.keys
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/pkg/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support'
|
3
|
+
require 'spec'
|
4
|
+
|
5
|
+
$LOAD_PATH << File.dirname(__FILE__) + '/../lib'
|
6
|
+
require File.dirname(__FILE__) + '/../init'
|
7
|
+
|
8
|
+
describe ActiveSupport::Cache::TokyoStore do
|
9
|
+
DB_FILE = File.expand_path(File.dirname(__FILE__) + '/../tmp/cache.tch')
|
10
|
+
PID_FILE = File.expand_path(File.dirname(__FILE__) + '/../tmp/cache.pid')
|
11
|
+
|
12
|
+
before :all do
|
13
|
+
`tchmgr create #{DB_FILE.to_str}`
|
14
|
+
`ttserver -dmn -le -pid #{PID_FILE.to_str} #{DB_FILE.to_str}`
|
15
|
+
end
|
16
|
+
|
17
|
+
after :all do
|
18
|
+
Process.kill('TERM', File.read(PID_FILE).to_i)
|
19
|
+
FileUtils.rm [DB_FILE, PID_FILE], :force => true
|
20
|
+
end
|
21
|
+
|
22
|
+
def write(*keys)
|
23
|
+
keys.each do |key|
|
24
|
+
@store.write key, "Plan #{key}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
before do
|
29
|
+
@store = ActiveSupport::Cache::TokyoStore.new
|
30
|
+
@store.clear
|
31
|
+
write 'A', 'B'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should perform basic operations' do
|
35
|
+
@store.read('A').should == 'Plan A'
|
36
|
+
@store.exist?('A').should be(true)
|
37
|
+
|
38
|
+
@store.read('C').should be_nil
|
39
|
+
@store.exist?('C').should be(false)
|
40
|
+
|
41
|
+
@store.write 'C', 'Plan C'
|
42
|
+
@store.read('C').should == 'Plan C'
|
43
|
+
|
44
|
+
@store.delete('A').should be(true)
|
45
|
+
@store.delete('D').should be(false)
|
46
|
+
@store.read('A').should be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should 'fetch' as evey other store" do
|
50
|
+
@store.exist?('C').should be(false)
|
51
|
+
@store.fetch('C').should be_nil
|
52
|
+
@store.fetch('C') do
|
53
|
+
'Plan C'
|
54
|
+
end.should == 'Plan C'
|
55
|
+
@store.fetch('C').should == 'Plan C'
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should be able to delete matching records" do
|
59
|
+
write 'c'
|
60
|
+
@store.keys.should == ['A', 'B', 'c']
|
61
|
+
@store.delete_matched /[A-Z]/
|
62
|
+
@store.keys.should == ['c']
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
data/tmp/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cache.*
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{tokyo-cache-store}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dimitrij Denissenko"]
|
12
|
+
s.date = %q{2009-09-19}
|
13
|
+
s.description = %q{Tokyo Tyrant cache store for ActiveSupport/Rails.}
|
14
|
+
s.email = %q{contact@dvisionfactory.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"MIT-LICENSE",
|
20
|
+
"README",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"init.rb",
|
24
|
+
"lib/active_support/cache/tokyo_store.rb",
|
25
|
+
"pkg/.gitignore",
|
26
|
+
"spec/tokyo_cache_store_spec.rb",
|
27
|
+
"tmp/.gitignore",
|
28
|
+
"tokyo-cache-store.gemspec"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/dim/tokyo-cache-store}
|
31
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.5}
|
34
|
+
s.summary = %q{Tokyo Tyrant Cache Store}
|
35
|
+
s.test_files = [
|
36
|
+
"spec/tokyo_cache_store_spec.rb"
|
37
|
+
]
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.0"])
|
45
|
+
s.add_runtime_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.2.0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.0"])
|
48
|
+
s.add_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.2.0"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<activesupport>, [">= 2.3.0"])
|
52
|
+
s.add_dependency(%q<actsasflinn-ruby-tokyotyrant>, [">= 0.2.0"])
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dim-tokyo-cache-store
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dimitrij Denissenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-19 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: actsasflinn-ruby-tokyotyrant
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.2.0
|
34
|
+
version:
|
35
|
+
description: Tokyo Tyrant cache store for ActiveSupport/Rails.
|
36
|
+
email: contact@dvisionfactory.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- README
|
43
|
+
files:
|
44
|
+
- MIT-LICENSE
|
45
|
+
- README
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- init.rb
|
49
|
+
- lib/active_support/cache/tokyo_store.rb
|
50
|
+
- pkg/.gitignore
|
51
|
+
- spec/tokyo_cache_store_spec.rb
|
52
|
+
- tmp/.gitignore
|
53
|
+
- tokyo-cache-store.gemspec
|
54
|
+
has_rdoc: false
|
55
|
+
homepage: http://github.com/dim/tokyo-cache-store
|
56
|
+
licenses:
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options:
|
59
|
+
- --charset=UTF-8
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 1.3.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Tokyo Tyrant Cache Store
|
81
|
+
test_files:
|
82
|
+
- spec/tokyo_cache_store_spec.rb
|