Skip to content

Commit

Permalink
feat(keydb): add redisgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
hongbo-miao committed May 3, 2022
1 parent fb08c4b commit 4cee21c
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 9 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,30 @@ jobs:
- name: Print Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}

push-hm-keydb:
name: Push hm-keydb to GitHub Container Registry
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./hm-keydb/Dockerfile
push: true
tags: ghcr.io/hongbo-miao/hm-keydb:latest
- name: Print Docker image digest
run: echo ${{ steps.docker_build.outputs.digest }}

push-hm-alpine:
name: Push hm-alpine to GitHub Container Registry
runs-on: ubuntu-20.04
Expand Down
4 changes: 0 additions & 4 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
community.general.homebrew:
name: ory-hydra
state: present
- name: Install presto
community.general.homebrew:
name: presto
state: present
- name: Install redis
community.general.homebrew:
name: redis
Expand Down
11 changes: 11 additions & 0 deletions keydb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM alpine:3.15.4 AS builder
RUN mkdir -p /usr/lib/keydb/modules/ \
&& wget https://github.com/Hongbo-Miao/hm-redis-modules/raw/main/redisgraph.Linux-ubuntu18.04-x86_64.2.8.11/redisgraph.so

FROM eqalpha/keydb:x86_64_v6.2.2
# https://github.com/RedisGraph/RedisGraph/blob/master/README.md#loading-redisgraph-into-redis
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y libgomp1
COPY --from=builder /usr/lib/keydb/modules/ /usr/lib/keydb/modules/
CMD ["keydb-server", "/etc/keydb/keydb.conf", "--loadmodule", "/usr/lib/keydb/modules/redisgraph.so"]
47 changes: 42 additions & 5 deletions keydb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ redis-cli-set:
redis-cli-get:
redis-cli GET hm-name

redis-benchmark:
redis-benchmark -a passw0rd

# Redis - publish/subscribe
redis-cli-subscribe:
redis-cli SUBSCRIBE hm-channel
Expand All @@ -39,13 +42,39 @@ redis-cli-lua-script-exists:
redis-cli-lua-script-flush:
redis-cli SCRIPT FLUSH

# Redis - Graph
redis-cli-module-list:
redis-cli MODULE LIST
redis-cli-graph-create-nodes:
# Each node represents an actor
redis-cli GRAPH.QUERY movies "CREATE (:Actor {name:'Mark Hamill', actor_id:1}), (:Actor {name:'Harrison Ford', actor_id:2}), (:Actor {name:'Carrie Fisher', actor_id:3})"
# This node represent a movie
redis-cli GRAPH.QUERY movies "CREATE (:Movie {title:'Star Wars: Episode V - The Empire Strikes Back', release_year: 1980 , movie_id:1})"
redis-cli-graph-create-relationships:
# Mark Hamill played Luke Skywalker in Star Wars: Episode V - The Empire Strikes Back'
redis-cli GRAPH.QUERY movies "MATCH (a:Actor),(m:Movie) WHERE a.actor_id = 1 AND m.movie_id = 1 CREATE (a)-[r:ACTED_IN {role:'Luke Skywalker'}]->(m) RETURN r"
# Harrison Ford played Han Solo
redis-cli GRAPH.QUERY movies "MATCH (a:Actor), (m:Movie) WHERE a.actor_id = 2 AND m.movie_id = 1 CREATE (a)-[r:ACTED_IN {role:'Han Solo'}]->(m) RETURN r"
# Carrie Fisher played Princess Leila
redis-cli GRAPH.QUERY movies "MATCH (a:Actor), (m:Movie) WHERE a.actor_id = 3 AND m.movie_id = 1 CREATE (a)-[r:ACTED_IN {role:'Princess Leila'}]->(m) RETURN r"
redis-cli-graph-viz:
redis-cli GRAPH.QUERY movies "MATCH (m:Movie) WHERE m.movie_id = 1 RETURN m"
redis-cli-graph-del:
redis-cli DEL movies

# Redis Stack
redis-stack-server:
redis-stack-server

# KeyDB
keydb-start:
keydb-server
keydb-stop:
keydb-cli SHUTDOWN
keydb-cli:
keydb-cli
keydb-cli-password:
keydb-cli --pass passw0rd
keydb-cli-ping:
keydb-cli PING
keydb-cli-keys:
Expand All @@ -61,11 +90,19 @@ keydb-cli-hmget:
keydb-start-multi-master:
keydb-server --multi-master yes --active-replica yes --replicaof 192.168.2.58 6379 --requirepass passw0rd --masterauth passw0rd
keydb-server --multi-master yes --active-replica yes --replicaof 192.168.2.117 6379 --requirepass passw0rd --masterauth passw0rd
keydb-cli-password:
keydb-cli --pass passw0rd
keydb-cli-lua-script-load:
keydb-cli --pass passw0rd SCRIPT LOAD "$$(cat greet.lua)"

#
redis-benchmark:
redis-benchmark -a passw0rd
# KeyDB - Docker
keydb-docker-build:
cd .. && \
docker build --file=keydb/Dockerfile --tag=ghcr.io/hongbo-miao/hm-keydb:latest .
keydb-docker-push:
docker push ghcr.io/hongbo-miao/hm-keydb:latest
keydb-docker-run:
docker run \
--detach \
--name=hm-keydb \
--publish=6379:6379 \
ghcr.io/hongbo-miao/hm-keydb:latest \
keydb-server /etc/keydb/keydb.conf --multi-master yes --active-replica yes --replicaof 192.168.2.58 6379 --requirepass passw0rd --masterauth passw0rd

0 comments on commit 4cee21c

Please sign in to comment.