Class: Roma::Storage::RubyHashStorage
- Inherits:
-
BasicStorage
- Object
- BasicStorage
- Roma::Storage::RubyHashStorage
- Defined in:
- lib/roma/storage/rh_storage.rb
Constant Summary
Constants inherited from BasicStorage
BasicStorage::PACK_HEADER_TEMPLATE, BasicStorage::PACK_TEMPLATE
Instance Attribute Summary
Attributes inherited from BasicStorage
#cleanup_regexp, #dbs, #divnum, #do_each_vn_dump, #each_clean_up_sleep, #each_vn_dump_sleep, #each_vn_dump_sleep_count, #error_message, #ext_name, #hdb, #hdiv, #logic_clock_expire, #option, #st_class, #storage_path, #vn_list
Instance Method Summary collapse
Methods inherited from BasicStorage
#add, #append, #cache_file_name, #cas, #close_log, #closedb, #db_get, #db_put, #decr, #delete, #dump, #each_cache_by_keys, #each_cache_dump_pack, #each_vn_dump, #flush_db, #get, #get_context, #get_keys_in_cache, #get_logfile_list, #get_raw, #get_raw2, #get_stat, #incr, #initialize, #load, #load_stream_dump, #load_stream_dump_for_cachecleaning, #open_log, #out, #out_cache, #prepend, #rdelete, #replace, #rset, #set, #set_db_stat, #set_expt, #stop_clean_up, #true_length, #write_log
Constructor Details
This class inherits a constructor from Roma::Storage::BasicStorage
Instance Method Details
#each_clean_up(t, vnhash) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/roma/storage/rh_storage.rb', line 26 def each_clean_up(t, vnhash) @do_clean_up = true nt = Time.now.to_i @hdb.each{ |hdb| keys = hdb.keys keys.each{ |k| v = hdb[k] return unless @do_clean_up vn, last, clk, expt = unpack_header(v) vn_stat = vnhash[vn] if vn_stat == :primary && ( (expt != 0 && nt > expt) || (expt == 0 && t > last) ) yield k, vn hdb.out(k) if hdb.get(k) == v elsif vn_stat == nil && t > last yield k, vn hdb.out(k) if hdb.get(k) == v end sleep @each_clean_up_sleep } } end |
#each_hdb_dump(i, except_vnh = nil) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/roma/storage/rh_storage.rb', line 66 def each_hdb_dump(i,except_vnh = nil) count = 0 keys = @hdb[i].keys keys.each{|k| v = @hdb[i][k] vn, last, clk, expt, val = unpack_data(v) if except_vnh && except_vnh.key?(vn) || Time.now.to_i > expt count += 1 sleep @each_vn_dump_sleep if count % @each_vn_dump_sleep_count == 0 else yield [vn, last, clk, expt, k.length, k, val.length, val].pack("NNNNNa#{k.length}Na#{val.length}") sleep @each_vn_dump_sleep end } end |
#opendb ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/roma/storage/rh_storage.rb', line 16 def opendb create_div_hash @divnum.times do |i| @hdb[i] = open_db(nil) @hdbc[i] = nil @dbs[i] = :normal end end |