metry 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +14 -69
- data/TODO +2 -3
- data/cucumber.yml +1 -0
- data/example/example.rb +1 -1
- data/features/psycho/dashboard.feature +17 -0
- data/features/psycho/goals.feature +24 -0
- data/features/psycho/visitor_tracking.feature +32 -0
- data/features/step_definitions/goals.rb +3 -0
- data/features/step_definitions/tracking.rb +1 -1
- data/features/step_definitions/web.rb +14 -2
- data/features/support/env.rb +4 -0
- data/lib/metry.rb +4 -6
- data/lib/metry/experiment.rb +6 -8
- data/lib/metry/psycho.rb +112 -0
- data/lib/metry/psycho/dashboard.erb +14 -0
- data/lib/metry/psycho/layout.erb +8 -0
- data/lib/metry/psycho/new_goal.erb +9 -0
- data/lib/metry/psycho/visitor.erb +7 -0
- data/lib/metry/rack/tracking.rb +17 -13
- data/lib/metry/storage.rb +116 -0
- data/radiant/example/features/metry.feature +8 -8
- data/radiant/example/features/psycho.feature +13 -0
- data/radiant/example/features/step_definitions/experiments.rb +2 -2
- data/radiant/example/features/step_definitions/tracking.rb +1 -1
- data/radiant/example/features/support/env.rb +3 -0
- data/radiant/extension/lib/metry_authenticator.rb +30 -0
- data/radiant/extension/lib/metry_tags.rb +2 -1
- data/radiant/extension/metry_extension.rb +1 -1
- data/test/{test_tokyo.rb → test_storage.rb} +3 -3
- metadata +17 -72
- data/lib/metry/memory.rb +0 -27
- data/lib/metry/tokyo.rb +0 -181
- data/vendor/rufus-tokyo/CHANGELOG.txt +0 -112
- data/vendor/rufus-tokyo/CREDITS.txt +0 -27
- data/vendor/rufus-tokyo/LICENSE.txt +0 -21
- data/vendor/rufus-tokyo/README.txt +0 -310
- data/vendor/rufus-tokyo/Rakefile +0 -118
- data/vendor/rufus-tokyo/TODO.txt +0 -25
- data/vendor/rufus-tokyo/doc/decision_table.numbers +0 -0
- data/vendor/rufus-tokyo/doc/rdoc-style.css +0 -320
- data/vendor/rufus-tokyo/lib/rufus-edo.rb +0 -3
- data/vendor/rufus-tokyo/lib/rufus-tokyo.rb +0 -3
- data/vendor/rufus-tokyo/lib/rufus/edo.rb +0 -39
- data/vendor/rufus-tokyo/lib/rufus/edo/README.txt +0 -106
- data/vendor/rufus-tokyo/lib/rufus/edo/cabcore.rb +0 -333
- data/vendor/rufus-tokyo/lib/rufus/edo/cabinet/abstract.rb +0 -219
- data/vendor/rufus-tokyo/lib/rufus/edo/cabinet/table.rb +0 -159
- data/vendor/rufus-tokyo/lib/rufus/edo/error.rb +0 -36
- data/vendor/rufus-tokyo/lib/rufus/edo/ntyrant.rb +0 -4
- data/vendor/rufus-tokyo/lib/rufus/edo/ntyrant/abstract.rb +0 -137
- data/vendor/rufus-tokyo/lib/rufus/edo/ntyrant/table.rb +0 -141
- data/vendor/rufus-tokyo/lib/rufus/edo/tabcore.rb +0 -567
- data/vendor/rufus-tokyo/lib/rufus/tokyo.rb +0 -58
- data/vendor/rufus-tokyo/lib/rufus/tokyo/cabinet/abstract.rb +0 -568
- data/vendor/rufus-tokyo/lib/rufus/tokyo/cabinet/lib.rb +0 -230
- data/vendor/rufus-tokyo/lib/rufus/tokyo/cabinet/table.rb +0 -753
- data/vendor/rufus-tokyo/lib/rufus/tokyo/cabinet/util.rb +0 -425
- data/vendor/rufus-tokyo/lib/rufus/tokyo/config.rb +0 -161
- data/vendor/rufus-tokyo/lib/rufus/tokyo/dystopia.rb +0 -43
- data/vendor/rufus-tokyo/lib/rufus/tokyo/dystopia/lib.rb +0 -65
- data/vendor/rufus-tokyo/lib/rufus/tokyo/dystopia/words.rb +0 -71
- data/vendor/rufus-tokyo/lib/rufus/tokyo/hmethods.rb +0 -111
- data/vendor/rufus-tokyo/lib/rufus/tokyo/query.rb +0 -102
- data/vendor/rufus-tokyo/lib/rufus/tokyo/transactions.rb +0 -74
- data/vendor/rufus-tokyo/lib/rufus/tokyo/ttcommons.rb +0 -59
- data/vendor/rufus-tokyo/lib/rufus/tokyo/tyrant.rb +0 -35
- data/vendor/rufus-tokyo/lib/rufus/tokyo/tyrant/abstract.rb +0 -146
- data/vendor/rufus-tokyo/lib/rufus/tokyo/tyrant/lib.rb +0 -153
- data/vendor/rufus-tokyo/lib/rufus/tokyo/tyrant/table.rb +0 -162
- data/vendor/rufus-tokyo/rufus-tokyo.gemspec +0 -25
- data/vendor/rufus-tokyo/spec/cabinet_spec.rb +0 -472
- data/vendor/rufus-tokyo/spec/cabinetconfig_spec.rb +0 -82
- data/vendor/rufus-tokyo/spec/edo_cabinet_spec.rb +0 -447
- data/vendor/rufus-tokyo/spec/edo_ntyrant_spec.rb +0 -299
- data/vendor/rufus-tokyo/spec/edo_ntyrant_table_spec.rb +0 -462
- data/vendor/rufus-tokyo/spec/edo_table_spec.rb +0 -560
- data/vendor/rufus-tokyo/spec/hmethods_spec.rb +0 -44
- data/vendor/rufus-tokyo/spec/incr.lua +0 -20
- data/vendor/rufus-tokyo/spec/spec.rb +0 -9
- data/vendor/rufus-tokyo/spec/spec_base.rb +0 -23
- data/vendor/rufus-tokyo/spec/start_tyrants.sh +0 -26
- data/vendor/rufus-tokyo/spec/stop_tyrants.sh +0 -9
- data/vendor/rufus-tokyo/spec/table_spec.rb +0 -567
- data/vendor/rufus-tokyo/spec/tyrant_spec.rb +0 -309
- data/vendor/rufus-tokyo/spec/tyrant_table_spec.rb +0 -479
- data/vendor/rufus-tokyo/spec/util_list_spec.rb +0 -200
- data/vendor/rufus-tokyo/spec/util_map_spec.rb +0 -132
- data/vendor/rufus-tokyo/tasks/dev.rb +0 -70
- data/vendor/rufus-tokyo/test/bm0.rb +0 -353
- data/vendor/rufus-tokyo/test/bm1_compression.rb +0 -54
- data/vendor/rufus-tokyo/test/con0.rb +0 -30
- data/vendor/rufus-tokyo/test/mem.rb +0 -49
- data/vendor/rufus-tokyo/test/mem1.rb +0 -44
- data/vendor/rufus-tokyo/test/readme0.rb +0 -17
- data/vendor/rufus-tokyo/test/readme1.rb +0 -21
- data/vendor/rufus-tokyo/test/readme2.rb +0 -15
- data/vendor/rufus-tokyo/test/readme3.rb +0 -24
- data/vendor/rufus-tokyo/test/readmes_test.sh +0 -17
@@ -1,39 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
|
-
|
25
|
-
|
26
|
-
begin
|
27
|
-
|
28
|
-
require 'tokyocabinet'
|
29
|
-
|
30
|
-
rescue LoadError
|
31
|
-
|
32
|
-
raise LoadError.new(
|
33
|
-
"tokyocabinet 'native' C bindings not present on your system, " +
|
34
|
-
"see http://github.com/jmettraux/rufus-tokyo/tree/master/lib/rufus/edo")
|
35
|
-
end
|
36
|
-
|
37
|
-
require 'rufus/edo/cabinet/abstract'
|
38
|
-
require 'rufus/edo/cabinet/table'
|
39
|
-
|
@@ -1,106 +0,0 @@
|
|
1
|
-
|
2
|
-
= Rufus::Edo
|
3
|
-
|
4
|
-
wrapping Hirabayashi-san's 'native' ruby bindings into a rubiyst-friendly set of Ruby classes.
|
5
|
-
|
6
|
-
In order to use Rufus::Edo, you have to have the libtokyocabinet dynamic library installed on your system :
|
7
|
-
|
8
|
-
http://openwferu.rubyforge.org/tokyo.html
|
9
|
-
|
10
|
-
Then you can install the 'native' C bindings.
|
11
|
-
|
12
|
-
NOTE : I have only tested those native bindings with Ruby 1.8.6. To run them with JRuby, the best option is Rufus::Tokyo and its FFI bindings.
|
13
|
-
|
14
|
-
NOTE : the Ruby tyrant library provided by Hirabayashi-san is not a C binding, it's a pure Ruby connector. It is slower than Rufus::Tokyo::Tyrant and Rufus::Tokyo::TyrantTable, but the advantage is that there is no need to install cabinet and tyrant C libraries to connect your Ruby code to your Tokyo Tyrant.
|
15
|
-
|
16
|
-
|
17
|
-
== installation of the 'native' C bindings
|
18
|
-
|
19
|
-
=== Careo's mirror gem
|
20
|
-
|
21
|
-
sudo gem install careo-tokyocabinet --source http://gems.github.com
|
22
|
-
|
23
|
-
|
24
|
-
=== directly from http://sf.net/tokyocabinet
|
25
|
-
|
26
|
-
Get the tokyocabinet-ruby package at :
|
27
|
-
|
28
|
-
http://sourceforge.net/project/showfiles.php?group_id=200242
|
29
|
-
|
30
|
-
unpack it :
|
31
|
-
|
32
|
-
tar xzvf tokyocabinet-ruby-1.20.tar.gz
|
33
|
-
cd tokyocabinet-ruby-1.20
|
34
|
-
|
35
|
-
and then, as described at : http://tokyocabinet.sourceforge.net/rubydoc/
|
36
|
-
|
37
|
-
ruby extconf.rb
|
38
|
-
make
|
39
|
-
sudo make install
|
40
|
-
|
41
|
-
|
42
|
-
== Rufus::Edo::Cabinet
|
43
|
-
|
44
|
-
require 'rufus/edo' # sudo gem install rufus-tokyo
|
45
|
-
|
46
|
-
db = Rufus::Edo::Cabinet.new('data.tch')
|
47
|
-
|
48
|
-
db['a'] = 'alpha'
|
49
|
-
|
50
|
-
# ...
|
51
|
-
|
52
|
-
db.close
|
53
|
-
|
54
|
-
|
55
|
-
== Rufus::Edo::Table
|
56
|
-
|
57
|
-
require 'rufus/edo'
|
58
|
-
|
59
|
-
db = Rufus::Edo::Table.new('data.tct')
|
60
|
-
|
61
|
-
db['customer1'] = { 'name' => 'Taira no Kyomori', 'age' => '55' }
|
62
|
-
|
63
|
-
# ...
|
64
|
-
|
65
|
-
db.close
|
66
|
-
|
67
|
-
|
68
|
-
== tyrant
|
69
|
-
|
70
|
-
Hirabayashi-san's pure Ruby gem for accessing Tokyo Tyrant can be installed with :
|
71
|
-
|
72
|
-
sudo gem install careo-tokyotyrant --source http://gems.github.com
|
73
|
-
|
74
|
-
It's also available at :
|
75
|
-
|
76
|
-
http://sourceforge.net/project/showfiles.php?group_id=200242
|
77
|
-
http://github.com/careo/tokyotyrant-ruby
|
78
|
-
|
79
|
-
|
80
|
-
== Rufus::Edo::NetTyrant
|
81
|
-
|
82
|
-
Note : 'NetTyrant' instead of 'Tyrant' to clearly show that this class isn't a C binding but a simple [pure Ruby] network implementation of a connection to a Tyrant.
|
83
|
-
|
84
|
-
|
85
|
-
require 'rufus/edo/ntyrant'
|
86
|
-
|
87
|
-
db = Rufus::Edo::NetTyrant.new('127.0.0.1', 45000)
|
88
|
-
|
89
|
-
db['a'] = 'alpha'
|
90
|
-
|
91
|
-
puts db['a]
|
92
|
-
# => 'alpha'
|
93
|
-
|
94
|
-
db.close
|
95
|
-
|
96
|
-
|
97
|
-
== Rufus::Edo::NetTyrantTable
|
98
|
-
|
99
|
-
require 'rufus/edo/ntyrant'
|
100
|
-
|
101
|
-
t = Rufus::Edo::NetTyrantTable.new('127.0.0.1', 44502)
|
102
|
-
|
103
|
-
t['client0'] = { 'name' => 'Heike no Kyomori', 'country' => 'jp' }
|
104
|
-
|
105
|
-
t.close
|
106
|
-
|
@@ -1,333 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2009, John Mettraux, jmettraux@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
|
-
|
25
|
-
|
26
|
-
require 'rufus/tokyo/hmethods'
|
27
|
-
require 'rufus/tokyo/transactions'
|
28
|
-
|
29
|
-
|
30
|
-
module Rufus::Edo
|
31
|
-
|
32
|
-
#
|
33
|
-
# The base cabinet methods are gathered here. They focus on wrapping
|
34
|
-
# Hirabayashi-san's methods.
|
35
|
-
#
|
36
|
-
# This module is included by Edo::Cabinet and Edo::NTyrant. Placing the
|
37
|
-
# methods in this module avoids having to load 'TokyoCabinet' when using
|
38
|
-
# only rufus/edo/ntyrant.
|
39
|
-
#
|
40
|
-
module CabinetCore
|
41
|
-
|
42
|
-
include Rufus::Tokyo::HashMethods
|
43
|
-
include Rufus::Tokyo::Transactions
|
44
|
-
|
45
|
-
def self.included (target_module)
|
46
|
-
|
47
|
-
target_module.module_eval do
|
48
|
-
#
|
49
|
-
# Same args as initialize, but can take a block form that will
|
50
|
-
# close the db when done. Similar to File.open (via Zev)
|
51
|
-
#
|
52
|
-
def self.open (name, params={})
|
53
|
-
db = self.new(name, params)
|
54
|
-
if block_given?
|
55
|
-
yield db
|
56
|
-
nil
|
57
|
-
else
|
58
|
-
db
|
59
|
-
end
|
60
|
-
ensure
|
61
|
-
db.close if block_given? && db
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Returns the path to this database.
|
67
|
-
#
|
68
|
-
def path
|
69
|
-
|
70
|
-
@path
|
71
|
-
end
|
72
|
-
|
73
|
-
# No comment
|
74
|
-
#
|
75
|
-
def []= (k, v)
|
76
|
-
@db.put(k, v) || raise_error
|
77
|
-
end
|
78
|
-
|
79
|
-
# No comment
|
80
|
-
#
|
81
|
-
def putkeep (k, v)
|
82
|
-
@db.putkeep(k, v)
|
83
|
-
end
|
84
|
-
|
85
|
-
# (The actual #[] method is provided by HashMethods)
|
86
|
-
#
|
87
|
-
def get (k)
|
88
|
-
@db.get(k)
|
89
|
-
end
|
90
|
-
protected :get
|
91
|
-
|
92
|
-
# Removes a record from the cabinet, returns the value if successful
|
93
|
-
# else nil.
|
94
|
-
#
|
95
|
-
def delete (k)
|
96
|
-
v = self[k]
|
97
|
-
@db.out(k) ? v : nil
|
98
|
-
end
|
99
|
-
|
100
|
-
# Returns the number of records in the 'cabinet'
|
101
|
-
#
|
102
|
-
def size
|
103
|
-
@db.rnum
|
104
|
-
end
|
105
|
-
|
106
|
-
# Removes all the records in the cabinet (use with care)
|
107
|
-
#
|
108
|
-
# Returns self (like Ruby's Hash does).
|
109
|
-
#
|
110
|
-
def clear
|
111
|
-
@db.vanish || raise_error
|
112
|
-
self
|
113
|
-
end
|
114
|
-
|
115
|
-
# Returns the 'weight' of the db (in bytes)
|
116
|
-
#
|
117
|
-
def weight
|
118
|
-
@db.fsiz
|
119
|
-
end
|
120
|
-
|
121
|
-
# Closes the cabinet (and frees the datastructure allocated for it),
|
122
|
-
# returns true in case of success.
|
123
|
-
#
|
124
|
-
def close
|
125
|
-
@db.close || raise_error
|
126
|
-
end
|
127
|
-
|
128
|
-
# Copies the current cabinet to a new file.
|
129
|
-
#
|
130
|
-
# Returns true if it was successful.
|
131
|
-
#
|
132
|
-
def copy (target_path)
|
133
|
-
@db.copy(target_path)
|
134
|
-
end
|
135
|
-
|
136
|
-
# Copies the current cabinet to a new file.
|
137
|
-
#
|
138
|
-
# Does it by copying each entry afresh to the target file. Spares some
|
139
|
-
# space, hence the 'compact' label...
|
140
|
-
#
|
141
|
-
def compact_copy (target_path)
|
142
|
-
@other_db = self.class.new(target_path)
|
143
|
-
self.each { |k, v| @other_db[k] = v }
|
144
|
-
@other_db.close
|
145
|
-
end
|
146
|
-
|
147
|
-
# "synchronize updated contents of an abstract database object with
|
148
|
-
# the file and the device"
|
149
|
-
#
|
150
|
-
def sync
|
151
|
-
@db.sync || raise_error
|
152
|
-
end
|
153
|
-
|
154
|
-
# Returns an array of all the primary keys in the db.
|
155
|
-
#
|
156
|
-
# With no options given, this method will return all the keys (strings)
|
157
|
-
# in a Ruby array.
|
158
|
-
#
|
159
|
-
# :prefix --> returns only the keys who match a given string prefix
|
160
|
-
#
|
161
|
-
# :limit --> returns a limited number of keys
|
162
|
-
#
|
163
|
-
def keys (options={})
|
164
|
-
|
165
|
-
if pref = options[:prefix]
|
166
|
-
|
167
|
-
@db.fwmkeys(pref, options[:limit] || -1)
|
168
|
-
|
169
|
-
else
|
170
|
-
|
171
|
-
limit = options[:limit] || -1
|
172
|
-
limit = nil if limit < 1
|
173
|
-
|
174
|
-
l = []
|
175
|
-
|
176
|
-
@db.iterinit
|
177
|
-
|
178
|
-
while (k = @db.iternext)
|
179
|
-
break if limit and l.size >= limit
|
180
|
-
l << k
|
181
|
-
end
|
182
|
-
|
183
|
-
l
|
184
|
-
end
|
185
|
-
end
|
186
|
-
|
187
|
-
# Deletes all the entries whose keys begin with the given prefix
|
188
|
-
#
|
189
|
-
def delete_keys_with_prefix (prefix)
|
190
|
-
|
191
|
-
# only ADB has the #misc method...
|
192
|
-
|
193
|
-
if @db.respond_to?(:misc)
|
194
|
-
@db.misc('outlist', @db.fwmkeys(prefix, -1))
|
195
|
-
else
|
196
|
-
@db.fwmkeys(prefix, -1).each { |k| self.delete(k) }
|
197
|
-
end
|
198
|
-
|
199
|
-
nil
|
200
|
-
end
|
201
|
-
|
202
|
-
# Given a list of keys, returns a Hash { key => value } of the
|
203
|
-
# matching entries (in one sweep).
|
204
|
-
#
|
205
|
-
# Warning : this is a naive (slow) implementation.
|
206
|
-
#
|
207
|
-
def lget (keys)
|
208
|
-
|
209
|
-
# only ADB has the #misc method...
|
210
|
-
|
211
|
-
if @db.respond_to?(:misc)
|
212
|
-
Hash[*@db.misc('getlist', keys)]
|
213
|
-
else
|
214
|
-
keys.inject({}) { |h, k| v = self[k]; h[k] = v if v; h }
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
#
|
219
|
-
# default impl provided by HashMethods
|
220
|
-
#
|
221
|
-
def merge! (hash)
|
222
|
-
|
223
|
-
# only ADB has the #misc method...
|
224
|
-
|
225
|
-
if @db.respond_to?(:misc)
|
226
|
-
@db.misc('putlist', hash.to_a.flatten)
|
227
|
-
else
|
228
|
-
super(hash)
|
229
|
-
end
|
230
|
-
self
|
231
|
-
end
|
232
|
-
alias :lput :merge!
|
233
|
-
|
234
|
-
# Given a list of keys, deletes all the matching entries (in one sweep).
|
235
|
-
#
|
236
|
-
# Warning : this is a naive (slow) implementation.
|
237
|
-
#
|
238
|
-
def ldelete (keys)
|
239
|
-
|
240
|
-
# only ADB has the #misc method...
|
241
|
-
|
242
|
-
if @db.respond_to?(:misc)
|
243
|
-
@db.misc('outlist', keys)
|
244
|
-
else
|
245
|
-
keys.each { |k| self.delete(k) }
|
246
|
-
end
|
247
|
-
|
248
|
-
nil
|
249
|
-
end
|
250
|
-
|
251
|
-
# Increments the value stored under the given key with the given increment
|
252
|
-
# (defaults to 1 (integer)).
|
253
|
-
#
|
254
|
-
def incr (key, val=1)
|
255
|
-
|
256
|
-
v = val.is_a?(Fixnum) ? @db.addint(key, val) : @db.adddouble(key, val)
|
257
|
-
|
258
|
-
raise(EdoError.new(
|
259
|
-
"incr failed, there is probably already a string value set " +
|
260
|
-
"for the key '#{key}'"
|
261
|
-
)) unless v
|
262
|
-
|
263
|
-
v
|
264
|
-
end
|
265
|
-
alias :adddouble :incr
|
266
|
-
alias :addint :incr
|
267
|
-
alias :add_double :incr
|
268
|
-
alias :add_int :incr
|
269
|
-
|
270
|
-
# Triggers a defrag (TC >= 1.4.21 only)
|
271
|
-
#
|
272
|
-
def defrag
|
273
|
-
|
274
|
-
raise(NotImplementedError.new(
|
275
|
-
"defrag (misc) only available when opening db with :type => :abstract"
|
276
|
-
)) unless @db.respond_to?(:misc)
|
277
|
-
|
278
|
-
@db.misc('defrag', [])
|
279
|
-
end
|
280
|
-
|
281
|
-
# Returns the underlying 'native' Ruby object (of the class devised by
|
282
|
-
# Hirabayashi-san)
|
283
|
-
#
|
284
|
-
def original
|
285
|
-
|
286
|
-
@db
|
287
|
-
end
|
288
|
-
|
289
|
-
# This is rather low-level, you'd better use #transaction like in
|
290
|
-
#
|
291
|
-
# db.transaction do
|
292
|
-
# db['a'] = 'alpha'
|
293
|
-
# db['b'] = 'bravo'
|
294
|
-
# db.abort if something_went_wrong?
|
295
|
-
# end
|
296
|
-
#
|
297
|
-
# Note that fixed-length dbs do not support transactions. It will result
|
298
|
-
# in a NoMethodError.
|
299
|
-
#
|
300
|
-
def tranbegin
|
301
|
-
@db.tranbegin
|
302
|
-
end
|
303
|
-
|
304
|
-
# This is rather low-level use #transaction and a block for a higher-level
|
305
|
-
# technique.
|
306
|
-
#
|
307
|
-
# Note that fixed-length dbs do not support transactions. It will result
|
308
|
-
# in a NoMethodError.
|
309
|
-
#
|
310
|
-
def trancommit
|
311
|
-
@db.trancommit
|
312
|
-
end
|
313
|
-
|
314
|
-
# This is rather low-level use #transaction and a block for a higher-level
|
315
|
-
# technique.
|
316
|
-
#
|
317
|
-
# Note that fixed-length dbs do not support transactions. It will result
|
318
|
-
# in a NoMethodError.
|
319
|
-
#
|
320
|
-
def tranabort
|
321
|
-
@db.tranabort
|
322
|
-
end
|
323
|
-
|
324
|
-
protected
|
325
|
-
|
326
|
-
def raise_error
|
327
|
-
code = @db.ecode
|
328
|
-
message = @db.errmsg(code)
|
329
|
-
raise EdoError.new("(err #{code}) #{message}")
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|