moneta 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/.travis.yml +39 -0
- data/Gemfile +61 -0
- data/LICENSE +2 -2
- data/README.md +450 -0
- data/Rakefile +29 -51
- data/SPEC.md +75 -0
- data/benchmarks/run.rb +195 -0
- data/lib/action_dispatch/middleware/session/moneta_store.rb +11 -0
- data/lib/active_support/cache/moneta_store.rb +55 -0
- data/lib/moneta.rb +121 -67
- data/lib/moneta/adapters/activerecord.rb +87 -0
- data/lib/moneta/adapters/cassandra.rb +91 -0
- data/lib/moneta/adapters/client.rb +69 -0
- data/lib/moneta/adapters/cookie.rb +35 -0
- data/lib/moneta/adapters/couch.rb +57 -0
- data/lib/moneta/adapters/datamapper.rb +75 -0
- data/lib/moneta/adapters/dbm.rb +25 -0
- data/lib/moneta/adapters/file.rb +79 -0
- data/lib/moneta/adapters/fog.rb +51 -0
- data/lib/moneta/adapters/gdbm.rb +25 -0
- data/lib/moneta/adapters/hbase.rb +101 -0
- data/lib/moneta/adapters/leveldb.rb +35 -0
- data/lib/moneta/adapters/localmemcache.rb +28 -0
- data/lib/moneta/adapters/lruhash.rb +85 -0
- data/lib/moneta/adapters/memcached.rb +11 -0
- data/lib/moneta/adapters/memcached_dalli.rb +69 -0
- data/lib/moneta/adapters/memcached_native.rb +70 -0
- data/lib/moneta/adapters/memory.rb +10 -0
- data/lib/moneta/adapters/mongo.rb +50 -0
- data/lib/moneta/adapters/null.rb +30 -0
- data/lib/moneta/adapters/pstore.rb +69 -0
- data/lib/moneta/adapters/redis.rb +68 -0
- data/lib/moneta/adapters/riak.rb +57 -0
- data/lib/moneta/adapters/sdbm.rb +35 -0
- data/lib/moneta/adapters/sequel.rb +79 -0
- data/lib/moneta/adapters/sqlite.rb +65 -0
- data/lib/moneta/adapters/tokyocabinet.rb +41 -0
- data/lib/moneta/adapters/yaml.rb +15 -0
- data/lib/moneta/base.rb +78 -0
- data/lib/moneta/builder.rb +39 -0
- data/lib/moneta/cache.rb +84 -0
- data/lib/moneta/expires.rb +71 -0
- data/lib/moneta/lock.rb +25 -0
- data/lib/moneta/logger.rb +61 -0
- data/lib/moneta/mixins.rb +65 -0
- data/lib/moneta/net.rb +18 -0
- data/lib/moneta/optionmerger.rb +39 -0
- data/lib/moneta/proxy.rb +86 -0
- data/lib/moneta/server.rb +81 -0
- data/lib/moneta/shared.rb +60 -0
- data/lib/moneta/stack.rb +78 -0
- data/lib/moneta/transformer.rb +159 -0
- data/lib/moneta/transformer/config.rb +42 -0
- data/lib/moneta/transformer/helper.rb +37 -0
- data/lib/moneta/version.rb +5 -0
- data/lib/moneta/wrapper.rb +33 -0
- data/lib/rack/cache/moneta.rb +93 -0
- data/lib/rack/moneta_cookies.rb +64 -0
- data/lib/rack/session/moneta.rb +63 -0
- data/moneta.gemspec +19 -0
- data/spec/action_dispatch/fixtures/session_autoload_test/foo.rb +10 -0
- data/spec/action_dispatch/session_moneta_store_spec.rb +196 -0
- data/spec/active_support/cache_moneta_store_spec.rb +197 -0
- data/spec/generate.rb +1489 -0
- data/spec/helper.rb +91 -0
- data/spec/moneta/adapter_activerecord_spec.rb +32 -0
- data/spec/moneta/adapter_cassandra_spec.rb +30 -0
- data/spec/moneta/adapter_client_spec.rb +19 -0
- data/spec/moneta/adapter_cookie_spec.rb +18 -0
- data/spec/moneta/adapter_couch_spec.rb +18 -0
- data/spec/moneta/adapter_datamapper_spec.rb +49 -0
- data/spec/moneta/adapter_dbm_spec.rb +18 -0
- data/spec/moneta/adapter_file_spec.rb +18 -0
- data/spec/moneta/adapter_fog_spec.rb +23 -0
- data/spec/moneta/adapter_gdbm_spec.rb +18 -0
- data/spec/moneta/adapter_hbase_spec.rb +18 -0
- data/spec/moneta/adapter_leveldb_spec.rb +18 -0
- data/spec/moneta/adapter_localmemcache_spec.rb +18 -0
- data/spec/moneta/adapter_lruhash_spec.rb +31 -0
- data/spec/moneta/adapter_memcached_dalli_spec.rb +30 -0
- data/spec/moneta/adapter_memcached_native_spec.rb +31 -0
- data/spec/moneta/adapter_memcached_spec.rb +30 -0
- data/spec/moneta/adapter_memory_spec.rb +39 -0
- data/spec/moneta/adapter_mongo_spec.rb +18 -0
- data/spec/moneta/adapter_pstore_spec.rb +21 -0
- data/spec/moneta/adapter_redis_spec.rb +30 -0
- data/spec/moneta/adapter_riak_spec.rb +22 -0
- data/spec/moneta/adapter_sdbm_spec.rb +18 -0
- data/spec/moneta/adapter_sequel_spec.rb +18 -0
- data/spec/moneta/adapter_sqlite_spec.rb +18 -0
- data/spec/moneta/adapter_tokyocabinet_bdb_spec.rb +18 -0
- data/spec/moneta/adapter_tokyocabinet_hdb_spec.rb +18 -0
- data/spec/moneta/adapter_yaml_spec.rb +21 -0
- data/spec/moneta/cache_file_memory_spec.rb +34 -0
- data/spec/moneta/cache_memory_null_spec.rb +23 -0
- data/spec/moneta/expires_file_spec.rb +76 -0
- data/spec/moneta/expires_memory_spec.rb +65 -0
- data/spec/moneta/lock_spec.rb +42 -0
- data/spec/moneta/null_adapter_spec.rb +26 -0
- data/spec/moneta/optionmerger_spec.rb +92 -0
- data/spec/moneta/proxy_expires_memory_spec.rb +55 -0
- data/spec/moneta/proxy_redis_spec.rb +23 -0
- data/spec/moneta/shared_spec.rb +30 -0
- data/spec/moneta/simple_activerecord_spec.rb +51 -0
- data/spec/moneta/simple_activerecord_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_cassandra_spec.rb +52 -0
- data/spec/moneta/simple_client_tcp_spec.rb +67 -0
- data/spec/moneta/simple_client_unix_spec.rb +53 -0
- data/spec/moneta/simple_couch_spec.rb +51 -0
- data/spec/moneta/simple_couch_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_datamapper_spec.rb +53 -0
- data/spec/moneta/simple_datamapper_with_expires_spec.rb +54 -0
- data/spec/moneta/simple_datamapper_with_repository_spec.rb +53 -0
- data/spec/moneta/simple_dbm_spec.rb +51 -0
- data/spec/moneta/simple_dbm_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_file_spec.rb +51 -0
- data/spec/moneta/simple_file_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_fog_spec.rb +56 -0
- data/spec/moneta/simple_fog_with_expires_spec.rb +58 -0
- data/spec/moneta/simple_gdbm_spec.rb +51 -0
- data/spec/moneta/simple_gdbm_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_hashfile_spec.rb +51 -0
- data/spec/moneta/simple_hashfile_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_hbase_spec.rb +51 -0
- data/spec/moneta/simple_hbase_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_leveldb_spec.rb +51 -0
- data/spec/moneta/simple_leveldb_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_localmemcache_spec.rb +51 -0
- data/spec/moneta/simple_localmemcache_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_lruhash_spec.rb +51 -0
- data/spec/moneta/simple_lruhash_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_memcached_dalli_spec.rb +52 -0
- data/spec/moneta/simple_memcached_native_spec.rb +52 -0
- data/spec/moneta/simple_memcached_spec.rb +52 -0
- data/spec/moneta/simple_memory_spec.rb +51 -0
- data/spec/moneta/simple_memory_with_compress_spec.rb +51 -0
- data/spec/moneta/simple_memory_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_memory_with_json_key_serializer_spec.rb +37 -0
- data/spec/moneta/simple_memory_with_json_serializer_spec.rb +28 -0
- data/spec/moneta/simple_memory_with_json_value_serializer_spec.rb +35 -0
- data/spec/moneta/simple_memory_with_prefix_spec.rb +51 -0
- data/spec/moneta/simple_memory_with_snappy_compress_spec.rb +51 -0
- data/spec/moneta/simple_mongo_spec.rb +51 -0
- data/spec/moneta/simple_mongo_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_null_spec.rb +36 -0
- data/spec/moneta/simple_pstore_spec.rb +51 -0
- data/spec/moneta/simple_pstore_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_redis_spec.rb +52 -0
- data/spec/moneta/simple_riak_spec.rb +55 -0
- data/spec/moneta/simple_riak_with_expires_spec.rb +56 -0
- data/spec/moneta/simple_sdbm_spec.rb +51 -0
- data/spec/moneta/simple_sdbm_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_sequel_spec.rb +51 -0
- data/spec/moneta/simple_sequel_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_sqlite_spec.rb +51 -0
- data/spec/moneta/simple_sqlite_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_tokyocabinet_spec.rb +51 -0
- data/spec/moneta/simple_tokyocabinet_with_expires_spec.rb +52 -0
- data/spec/moneta/simple_yaml_spec.rb +50 -0
- data/spec/moneta/simple_yaml_with_expires_spec.rb +51 -0
- data/spec/moneta/stack_file_memory_spec.rb +25 -0
- data/spec/moneta/stack_memory_file_spec.rb +24 -0
- data/spec/moneta/transformer_bencode_spec.rb +30 -0
- data/spec/moneta/transformer_bert_spec.rb +30 -0
- data/spec/moneta/transformer_bson_spec.rb +30 -0
- data/spec/moneta/transformer_bzip2_spec.rb +27 -0
- data/spec/moneta/transformer_json_spec.rb +30 -0
- data/spec/moneta/transformer_lzma_spec.rb +27 -0
- data/spec/moneta/transformer_lzo_spec.rb +27 -0
- data/spec/moneta/transformer_marshal_base64_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_escape_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_hmac_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_md5_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_md5_spread_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_prefix_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_rmd160_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_sha1_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_sha256_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_sha384_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_sha512_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_truncate_spec.rb +54 -0
- data/spec/moneta/transformer_marshal_uuencode_spec.rb +54 -0
- data/spec/moneta/transformer_msgpack_spec.rb +30 -0
- data/spec/moneta/transformer_ox_spec.rb +51 -0
- data/spec/moneta/transformer_quicklz_spec.rb +27 -0
- data/spec/moneta/transformer_snappy_spec.rb +27 -0
- data/spec/moneta/transformer_tnet_spec.rb +30 -0
- data/spec/moneta/transformer_yaml_spec.rb +51 -0
- data/spec/moneta/transformer_zlib_spec.rb +27 -0
- data/spec/monetaspecs.rb +2663 -0
- data/spec/rack/cache_moneta_spec.rb +355 -0
- data/spec/rack/moneta_cookies_spec.rb +81 -0
- data/spec/rack/session_moneta_spec.rb +305 -0
- metadata +359 -56
- data/README +0 -51
- data/TODO +0 -4
- data/lib/moneta/basic_file.rb +0 -111
- data/lib/moneta/berkeley.rb +0 -53
- data/lib/moneta/couch.rb +0 -63
- data/lib/moneta/datamapper.rb +0 -117
- data/lib/moneta/file.rb +0 -91
- data/lib/moneta/lmc.rb +0 -52
- data/lib/moneta/memcache.rb +0 -52
- data/lib/moneta/memory.rb +0 -11
- data/lib/moneta/mongodb.rb +0 -58
- data/lib/moneta/redis.rb +0 -49
- data/lib/moneta/rufus.rb +0 -41
- data/lib/moneta/s3.rb +0 -162
- data/lib/moneta/sdbm.rb +0 -33
- data/lib/moneta/tyrant.rb +0 -58
- data/lib/moneta/xattr.rb +0 -58
data/spec/helper.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'moneta'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'monetaspecs'
|
4
|
+
|
5
|
+
module Moneta
|
6
|
+
class Transformer < Proxy
|
7
|
+
class << self
|
8
|
+
alias_method :verbose_new, :new
|
9
|
+
|
10
|
+
def new(adapter, options = {})
|
11
|
+
options[:quiet] = true
|
12
|
+
verbose_new(adapter, options)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Value
|
19
|
+
attr_accessor :x
|
20
|
+
def initialize(x)
|
21
|
+
@x = x
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
Value === other && other.x == x
|
26
|
+
end
|
27
|
+
|
28
|
+
def eql?(other)
|
29
|
+
Value === other && other.x == x
|
30
|
+
end
|
31
|
+
|
32
|
+
def hash
|
33
|
+
x.hash
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def make_tempdir
|
38
|
+
# Expand path since datamapper needs absolute path in setup
|
39
|
+
tempdir = File.expand_path(File.join(File.dirname(__FILE__), 'tmp'))
|
40
|
+
FileUtils.mkpath(tempdir)
|
41
|
+
tempdir
|
42
|
+
end
|
43
|
+
|
44
|
+
def marshal_error
|
45
|
+
# HACK: Marshalling structs in rubinius without class name throws
|
46
|
+
# NoMethodError (to_sym). TODO: Create an issue for rubinius!
|
47
|
+
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
|
48
|
+
RUBY_VERSION < '1.9' ? ArgumentError : NoMethodError
|
49
|
+
else
|
50
|
+
TypeError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class InitializeStore
|
55
|
+
def initialize(&block)
|
56
|
+
instance_eval(&block)
|
57
|
+
store = new_store
|
58
|
+
store['foo'] = 'bar'
|
59
|
+
store.clear
|
60
|
+
store.close
|
61
|
+
end
|
62
|
+
|
63
|
+
def method_missing(*args)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def describe_moneta(name, &block)
|
68
|
+
begin
|
69
|
+
InitializeStore.new(&block)
|
70
|
+
describe(name, &block)
|
71
|
+
rescue LoadError => ex
|
72
|
+
puts "\e[31mTest #{name} not executed: #{ex.message}\e[0m"
|
73
|
+
rescue Exception => ex
|
74
|
+
puts "\e[31mTest #{name} not executed: #{ex.message}\e[0m"
|
75
|
+
puts ex.backtrace.join("\n")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
shared_context 'setup_store' do
|
80
|
+
let(:store) do
|
81
|
+
new_store
|
82
|
+
end
|
83
|
+
|
84
|
+
before do
|
85
|
+
store.clear
|
86
|
+
end
|
87
|
+
|
88
|
+
after do
|
89
|
+
store.close.should == nil if store
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_activerecord" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::ActiveRecord.new(:connection => { :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'adapter_activerecord') })
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
it 'updates an existing key/value' do
|
19
|
+
store['foo/bar'] = '1'
|
20
|
+
store['foo/bar'] = '2'
|
21
|
+
records = store.table.find :all, :conditions => { :k => 'foo/bar' }
|
22
|
+
records.count.should == 1
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'uses an existing connection' do
|
26
|
+
ActiveRecord::Base.establish_connection :adapter => (defined?(JRUBY_VERSION) ? 'jdbcsqlite3' : 'sqlite3'), :database => File.join(make_tempdir, 'activerecord-existing')
|
27
|
+
|
28
|
+
store = Moneta::Adapters::ActiveRecord.new
|
29
|
+
store.table.should be_table_exists
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_cassandra" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Cassandra.new(:keyspace => 'adapter_cassandra')
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'not_increment'
|
18
|
+
it_should_behave_like 'expires_stringkey_stringvalue'
|
19
|
+
it 'should support default expiration time' do
|
20
|
+
store = Moneta::Adapters::Cassandra.new(:expires => 2, :keyspace => 'adapter_cassandra')
|
21
|
+
store.store('key1', 'val1')
|
22
|
+
store.store('key2', 'val2', :expires => 60)
|
23
|
+
store.load('key1').should == 'val1'
|
24
|
+
sleep 1
|
25
|
+
store.load('key1').should == 'val1'
|
26
|
+
sleep 2
|
27
|
+
store.load('key1').should == nil
|
28
|
+
store['key2'].should == 'val2'
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_client" do
|
5
|
+
$tcp_server ||= Moneta::Server.new(Moneta::Adapters::Memory.new)
|
6
|
+
def new_store
|
7
|
+
Moneta::Adapters::Client.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def load_value(value)
|
11
|
+
Marshal.load(value)
|
12
|
+
end
|
13
|
+
|
14
|
+
include_context 'setup_store'
|
15
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'increment'
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_cookie" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Cookie.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_couch" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::Couch.new(:db => 'adapter_couch')
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'not_increment'
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_datamapper" do
|
5
|
+
require 'dm-core'
|
6
|
+
DataMapper.setup(:default, :adapter => :in_memory)
|
7
|
+
def new_store
|
8
|
+
Moneta::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/adapter_datamapper")
|
9
|
+
end
|
10
|
+
|
11
|
+
def load_value(value)
|
12
|
+
Marshal.load(value)
|
13
|
+
end
|
14
|
+
|
15
|
+
include_context 'setup_store'
|
16
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
19
|
+
it_should_behave_like 'not_increment'
|
20
|
+
it 'does not cross contaminate when storing' do
|
21
|
+
first = Moneta::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
|
22
|
+
first.clear
|
23
|
+
|
24
|
+
second = Moneta::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
|
25
|
+
second.clear
|
26
|
+
|
27
|
+
first['key'] = 'value'
|
28
|
+
second['key'] = 'value2'
|
29
|
+
|
30
|
+
first['key'].should == 'value'
|
31
|
+
second['key'].should == 'value2'
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'does not cross contaminate when deleting' do
|
35
|
+
first = Moneta::Adapters::DataMapper.new(:setup => "sqlite3://#{make_tempdir}/datamapper-first")
|
36
|
+
first.clear
|
37
|
+
|
38
|
+
second = Moneta::Adapters::DataMapper.new(:repository => :sample, :setup => "sqlite3://#{make_tempdir}/datamapper-second")
|
39
|
+
second.clear
|
40
|
+
|
41
|
+
first['key'] = 'value'
|
42
|
+
second['key'] = 'value2'
|
43
|
+
|
44
|
+
first.delete('key').should == 'value'
|
45
|
+
first.key?('key').should == false
|
46
|
+
second['key'].should == 'value2'
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_dbm" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::DBM.new(:file => File.join(make_tempdir, "adapter_dbm"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_file" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::File.new(:dir => File.join(make_tempdir, "adapter_file"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_fog" do
|
5
|
+
require 'fog'
|
6
|
+
Fog.mock!
|
7
|
+
def new_store
|
8
|
+
Moneta::Adapters::Fog.new(:aws_access_key_id => 'fake_access_key_id',
|
9
|
+
:aws_secret_access_key => 'fake_secret_access_key',
|
10
|
+
:provider => 'AWS',
|
11
|
+
:dir => 'moneta')
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_value(value)
|
15
|
+
Marshal.load(value)
|
16
|
+
end
|
17
|
+
|
18
|
+
include_context 'setup_store'
|
19
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
20
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
21
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
22
|
+
it_should_behave_like 'not_increment'
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_gdbm" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::GDBM.new(:file => File.join(make_tempdir, "adapter_gdbm"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_hbase" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::HBase.new(:table => 'adapter_hbase')
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_leveldb" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::LevelDB.new(:dir => File.join(make_tempdir, "adapter_leveldb"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_localmemcache" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::LocalMemCache.new(:file => File.join(make_tempdir, "adapter_localmemcache"))
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'not_increment'
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_lruhash" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::LRUHash.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'increment'
|
18
|
+
it 'should delete oldest' do
|
19
|
+
store = Moneta::Adapters::LRUHash.new(:max_size => 10)
|
20
|
+
store[0] = 'y'
|
21
|
+
(1..1000).each do |i|
|
22
|
+
store[i] = 'x'
|
23
|
+
store[0].should == 'y'
|
24
|
+
store.instance_variable_get(:@entry).size.should == [10, i+1].min
|
25
|
+
(0...[9, i-1].min).each do |j|
|
26
|
+
store.instance_variable_get(:@entry)[i-j].should_not be_nil
|
27
|
+
end
|
28
|
+
store.key?(i-9).should be_false if i > 9
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Generated by generate.rb
|
2
|
+
require 'helper'
|
3
|
+
|
4
|
+
describe_moneta "adapter_memcached_dalli" do
|
5
|
+
def new_store
|
6
|
+
Moneta::Adapters::MemcachedDalli.new(:namespace => "adapter_memcached_dalli")
|
7
|
+
end
|
8
|
+
|
9
|
+
def load_value(value)
|
10
|
+
Marshal.load(value)
|
11
|
+
end
|
12
|
+
|
13
|
+
include_context 'setup_store'
|
14
|
+
it_should_behave_like 'null_stringkey_stringvalue'
|
15
|
+
it_should_behave_like 'store_stringkey_stringvalue'
|
16
|
+
it_should_behave_like 'returndifferent_stringkey_stringvalue'
|
17
|
+
it_should_behave_like 'expires_stringkey_stringvalue'
|
18
|
+
it_should_behave_like 'increment'
|
19
|
+
it 'should support default expiration time' do
|
20
|
+
store = Moneta::Adapters::MemcachedDalli.new(:expires => 2, :namespace => "adapter_memcached_dalli")
|
21
|
+
store.store('key1', 'val1')
|
22
|
+
store.store('key2', 'val2', :expires => 60)
|
23
|
+
store.load('key1').should == 'val1'
|
24
|
+
sleep 1
|
25
|
+
store.load('key1').should == 'val1'
|
26
|
+
sleep 2
|
27
|
+
store.load('key1').should == nil
|
28
|
+
store['key2'].should == 'val2'
|
29
|
+
end
|
30
|
+
end
|