class Orchestrate::Application::SimpleCacheCollection

Class SimpleCacheCollection

Attributes

events[R]
graphs[R]
name[R]
primary_keys[R]

Public Class Methods

new(name) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 37
def initialize(name)
  @name = name
  @primary_keys, @events, @graphs = {}, {}, {}
end

Public Instance Methods

fetch(key) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 46
def fetch(key)
  # puts "SCC-fetching: '#{key}', '#{primary_keys[key]}'"
  if primary_keys[key]
    # puts "SCC-fetching: '#{primary_keys[key].ref}'"
    SimpleCacheRefs.instance.document primary_keys[key].ref
  end
end
fetch_events(key, etype) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 54
def fetch_events(key, etype)
  # puts "SCC-fetch_events: '#{key}', '#{etype}'"
  if primary_keys[key] and primary_keys[key].events[etype]
    primary_keys[key].events[etype].map { |ref|
      # puts "SCC-fetch_events: '#{ref}'"
      SimpleCacheRefs.instance.document ref
    }
  end
end
fetch_graph(key, kind) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 64
def fetch_graph(key, kind)
  # puts "SCC-fetch_graph 1: '#{key}', '#{kind}'"
  if primary_keys[key] and primary_keys[key].graphs and primary_keys[key].graphs[kind]
    primary_keys[key].graphs[kind].map { |ref|
      # puts "SCC-fetch_graph: '#{ref}'"
      SimpleCacheRefs.instance.document ref
    }
  end
end
flush!() click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 42
def flush!
  @primary_keys, @events, @graphs = {}, {}, {}
end
get_ref(key) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 74
def get_ref(key)
  primary_keys[key] and primary_keys[key].ref
end
save(data) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 78
def save(data)
  key, ref = data.key, data.ref
  @primary_keys[key] = PrimaryKey.new(ref) if primary_keys[key].nil?
  if data.respond_to? :etype and data.etype
    @primary_keys[key].add_event(data.etype, ref)
  else
    @primary_keys[key].ref = ref
  end
end
save_event(data) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 88
def save_event(data)
  @primary_keys[data.key] = PrimaryKey.new(0) if primary_keys[data.key].nil?
  @primary_keys[data.key].add_event data.etype
end
save_graph(data) click to toggle source
# File rails/lib/orchestrate_application/simple_cache_store.rb, line 93
def save_graph(data)
  @primary_keys[data.from_key] = PrimaryKey.new(0) if primary_keys[data.from_key].nil?
  @primary_keys[data.from_key].add_graph data
end