Class: GameMachine::WriteBehindCache
- Inherits:
-
Actor::Base
- Object
- JavaLib::UntypedActor
- Actor::Base
- GameMachine::WriteBehindCache
- Defined in:
- lib/game_machine/write_behind_cache.rb
Constant Summary
Constants inherited from Actor::Base
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#max_writes_per_second ⇒ Object
Returns the value of attribute max_writes_per_second.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#write_interval ⇒ Object
Returns the value of attribute write_interval.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Actor::Base
add_hashring, aspect, aspects, find, find_by_address, find_distributed, find_distributed_local, find_remote, hashring, hashrings, local_path, model_filter, #onReceive, player_controller, #receive_message, reset_hashrings, #schedule_message, #sender, set_player_controller
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
21 22 23 |
# File 'lib/game_machine/write_behind_cache.rb', line 21 def cache @cache end |
#max_writes_per_second ⇒ Object
Returns the value of attribute max_writes_per_second.
20 21 22 |
# File 'lib/game_machine/write_behind_cache.rb', line 20 def max_writes_per_second @max_writes_per_second end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
21 22 23 |
# File 'lib/game_machine/write_behind_cache.rb', line 21 def queue @queue end |
#write_interval ⇒ Object
Returns the value of attribute write_interval.
20 21 22 |
# File 'lib/game_machine/write_behind_cache.rb', line 20 def write_interval @write_interval end |
Class Method Details
.max_writes_per_second ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/game_machine/write_behind_cache.rb', line 4 def self.max_writes_per_second if @max_writes_per_second @max_writes_per_second else @max_writes_per_second = Application.config.cache_writes_per_second end end |
.write_interval ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/game_machine/write_behind_cache.rb', line 12 def self.write_interval if @write_interval @write_interval else @write_interval = Application.config.cache_write_interval end end |
Instance Method Details
#on_receive(message) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/game_machine/write_behind_cache.rb', line 40 def on_receive() if .is_a?(String) () else () if () write() elsif eligible_for_write?() write() else enqueue(.id) end end end |
#post_init(*args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/game_machine/write_behind_cache.rb', line 23 def post_init(*args) @write_interval = self.class.write_interval @max_writes_per_second = self.class.max_writes_per_second @store = DataStore.instance @cache = {} @updates = {} @queue = [] @queue_map = {} @last_write = current_time - (120 * 1000) @scheduler = get_context.system.scheduler @dispatcher = get_context.system.dispatcher unless @write_interval == -1 && @max_writes_per_second == -1 schedule_queue_run schedule_queue_stats end end |