Sha256: 258692e296651a090aa285764c6f989207b2ec71e4a3c14b84c0be67d73ab87e
Contents?: true
Size: 1.37 KB
Versions: 7
Compression:
Stored size: 1.37 KB
Contents
class ReeDao::DaoCache include Ree::BeanDSL bean :dao_cache do link :deep_dup, from: :ree_object singleton after_init :setup end def setup @thread_groups = {} end def add_thread_group_cache(thread_group) @thread_groups[thread_group.object_id] ||= {} end def drop_thread_group_cache(thread_group) @thread_groups.delete(thread_group.object_id) end def get(table_name, primary_key) add_thread_group_cache(current_thread_group) add_table_name(table_name) @thread_groups[current_thread_group.object_id][table_name][primary_key] end def set(table_name, primary_key, data) add_thread_group_cache(current_thread_group) add_table_name(table_name) add_primary_key(table_name, primary_key) @thread_groups[current_thread_group.object_id][table_name][primary_key] = deep_dup(data) end def drop_table_cache(table_name) add_thread_group_cache(current_thread_group) @thread_groups[current_thread_group.object_id].delete(table_name) end private def current_thread_group Thread.current.group end def add_table_name(thread_group = Thread.current.group, table_name) @thread_groups[thread_group.object_id][table_name] ||= {} end def add_primary_key(thread_group = Thread.current.group, table_name, primary_key) @thread_groups[thread_group.object_id][table_name][primary_key] ||= {} end end
Version data entries
7 entries across 7 versions & 1 rubygems