Class: Archipelago::Hashish::DumpHashish
- Inherits:
-
Object
- Object
- Archipelago::Hashish::DumpHashish
show all
- Includes:
- CachedHashish
- Defined in:
- lib/archipelago/hashish.rb
Overview
An Archipelago::Dump network backed CachedHashish.
Instance Method Summary
collapse
#[], #[]=, #delete, #first, #forget, #get_deep_clone, #get_from_db, #include?, #initialize_cached_hashish, #last, #store_if_changed, #timestamp, #without_lock, #write_to_db
#lock_on, #mon_check_owner, #synchronize_on, #unlock_on
Constructor Details
#initialize(officer) ⇒ DumpHashish
Initialize a new DumpHashish with the given officer to find Dumps.
301
302
303
304
305
306
|
# File 'lib/archipelago/hashish.rb', line 301
def initialize(officer)
super()
initialize_cached_hashish
@officer = officer
@hash_by_key = {}
end
|
Instance Method Details
#changed?(serialized_key, serialized_value) ⇒ Boolean
307
308
309
|
# File 'lib/archipelago/hashish.rb', line 307
def changed?(serialized_key, serialized_value)
return (old_hash = @hash_by_key[serialized_key]) && old_hash != Digest::SHA1.hexdigest(serialized_value)
end
|
#close! ⇒ Object
318
319
|
# File 'lib/archipelago/hashish.rb', line 318
def close!
end
|
#db_include?(key) ⇒ Boolean
323
324
325
|
# File 'lib/archipelago/hashish.rb', line 323
def db_include?(key)
return !@officer[officer_key(Marshal.dump(key), "content")].nil?
end
|
#do_delete_from_persistence(serialized_key) ⇒ Object
331
332
333
334
335
|
# File 'lib/archipelago/hashish.rb', line 331
def do_delete_from_persistence(serialized_key)
@officer.delete(officer_key(serialized_key, "content"))
@officer.delete(officer_key(serialized_key, "timestamp"))
@hash_by_key[serialized_key] = Digest::SHA1.hexdigest(serialized_value)
end
|
#do_get_from_db(serialized_key) ⇒ Object
326
327
328
329
330
|
# File 'lib/archipelago/hashish.rb', line 326
def do_get_from_db(serialized_key)
serialized_value = @officer[officer_key(serialized_key, "content")]
@hash_by_key[serialized_key] = Digest::SHA1.hexdigest(serialized_value) if serialized_value
return serialized_value
end
|
#do_get_timestamp_from_db(serialized_key) ⇒ Object
310
311
312
|
# File 'lib/archipelago/hashish.rb', line 310
def do_get_timestamp_from_db(serialized_key)
return @officer[officer_key(serialized_key, "timestamp")]
end
|
#do_write_to_db(key, serialized_key, serialized_value, now) ⇒ Object
313
314
315
316
317
|
# File 'lib/archipelago/hashish.rb', line 313
def do_write_to_db(key, serialized_key, serialized_value, now)
@officer[officer_key(serialized_key, "content")] = serialized_value
@officer[officer_key(serialized_key, "timestamp")] = Marshal.dump(now)
@hash_by_key[serialized_key] = Digest::SHA1.hexdigest(serialized_value)
end
|
#each(callable) ⇒ Object
336
337
338
|
# File 'lib/archipelago/hashish.rb', line 336
def each(callable)
raise "You have to implement me!"
end
|
#officer_key(serialized_key, space) ⇒ Object
320
321
322
|
# File 'lib/archipelago/hashish.rb', line 320
def officer_key(serialized_key, space)
Digest::SHA1.hexdigest("Archipelago::Hashish::DumpHashish:#{space}:#{serialized_key}")
end
|