module EventCache
this file is part of manqod manqod is distributed under the CDDL licence the owner of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)
Public Instance Methods
events(gtk_object_id,force_load=false)
click to toggle source
# File lib/DrbDB/EventCache.rb, line 21 def events(gtk_object_id,force_load=false) if force_load begin cache.delete("ev#{gtk_object_id}") rescue Memcached::NotFound end cnt=0 a=Hash.new admin.rows("select * from events where gtkobjectid = '#{gtk_object_id}'").each{|row| a[row['event']]=Array.new unless a.has_key?(row['event']) a[row['event']].push(row['command']) cnt+=1 } cache.set("ev#{gtk_object_id}",a) if a.size>0 einfo("loaded #{cnt.inspect} events for #{gtk_object_id.inspect}") end begin a=cache.set("ev#{gtk_object_id}",a) rescue Memcached::NotFound a=Array.new end a end
load_all_events()
click to toggle source
# File lib/DrbDB/EventCache.rb, line 7 def load_all_events cnt=0 admin.rows("select distinct gtkobjectid from events").each{|evid| a=Hash.new admin.rows("select * from events where gtkobjectid = '#{evid['gtkobjectid']}'").each{|row| a[row['event']]=Array.new unless a.has_key?(row['event']) a[row['event']].push(row['command']) cnt+=1 } cache.set("ev#{evid['gtkobjectid']}",a) } einfo("loaded #{cnt} events") end