module Redis::Graph
Overview
RedisGraph is a graph database built on top of Redis that you query using the Cypher query language.
If your Redis server is running RedisGraph (for example, using Redis
Stack), you can branch off of your existing
Redis::Client
using the Redis::Client#graph
method:
require "redis/graph"
struct Person
include Redis::Graph::Serializable::Node
getter id : Int64
getter name : String
end
redis = Redis::Client.new
# Store the graph data in the Redis key "my-graph"
graph = redis.graph(key: "my-graph")
# Create some data in our graph
graph.write_query <<-CYPHER, id: 123, name: "Jamie"
CREATE (person:Person{id: $id, name: $name})
CYPHER
# The `return` argument specifies the return types of the results in your
# Cypher query's `RETURN` clause
pp graph.read_query(<<-CYPHER, {id: 123}, return: {Person})
MATCH (person:Person{id: $id})
RETURN person
CYPHER
# => [{Person(
# @id=123,
# @name="Jamie",
# @node=
# Redis::Graph::Serializable::Node::Metadata(@id=0, @labels=["Person"]))}]
In addition to basic Redis property types, Redis::Graph::Serializable
types
also support Bool
, UUID
, and Time
.
EXPERIMENTAL The Redis::Graph
API is experimental and may be subject to change.
Defined in:
graph.crgraph/cache.cr
graph/node.cr
graph/relationship.cr
graph/serializable.cr
graph/value.cr
graph/value_type.cr