class RedisGraph::Metadata
Public Class Methods
new(opts = {})
click to toggle source
# File lib/redisgraph.rb, line 14 def initialize(opts = {}) @graphname = opts[:graphname] @connection = opts[:connection] # cache semantics around these labels, propertyKeys, and relationshipTypes # defers first read and is invalidated when changed. @labels_proc = -> { call_procedure('db.labels') } @property_keys_proc = -> { call_procedure('db.propertyKeys') } @relationship_types_proc = -> { call_procedure('db.relationshipTypes') } end
Public Instance Methods
call_procedure(procedure)
click to toggle source
# File lib/redisgraph.rb, line 41 def call_procedure(procedure) res = @connection.call("GRAPH.QUERY", @graphname, "CALL #{procedure}()") res[1].flatten rescue Redis::CommandError => e raise CallError, e end
invalidate()
click to toggle source
# File lib/redisgraph.rb, line 25 def invalidate @labels = @property_keys = @relationship_types = nil end
labels()
click to toggle source
# File lib/redisgraph.rb, line 29 def labels @labels ||= @labels_proc.call end
property_keys()
click to toggle source
# File lib/redisgraph.rb, line 33 def property_keys @property_keys ||= @property_keys_proc.call end
relationship_types()
click to toggle source
# File lib/redisgraph.rb, line 37 def relationship_types @relationship_types ||= @relationship_types_proc.call end