data-storage/hm-keydb/Makefile
# Redis
redis-start:
redis-server
redis-start-password:
redis-server --requirepass passw0rd --masterauth passw0rd
redis-stop:
redis-cli SHUTDOWN
redis-cli:
redis-cli
redis-cli-password:
redis-cli --pass passw0rd
redis-cli-ping:
redis-cli PING
redis-cli-keys:
redis-cli KEYS "*"
redis-cli-set:
redis-cli SET hm-name Hongbo
redis-cli-get:
redis-cli GET hm-name
redis-cli-hmget:
redis-cli HMGET trending-twitter-hashtags field1 field2
redis-benchmark:
redis-benchmark -a passw0rd
# Redis - publish/subscribe
redis-cli-subscribe:
redis-cli SUBSCRIBE hm-channel
redis-cli-publish:
redis-cli PUBLISH hm-channel "foo"
# Redis - Lua
redis-cli-lua:
redis-cli EVAL 'return ARGV[1].." "..redis.call("GET",KEYS[1])' 1 hm-name "Hello"
redis-cli-lua-script-run:
redis-cli --eval greet.lua hm-name , Hello
redis-cli-lua-script-load:
redis-cli SCRIPT LOAD "$$(cat greet.lua)"
redis-cli-lua-script-run-by-hash:
redis-cli EVALSHA c72b1fc2261c116957bbc839b558190a23d1cbb3 1 hm-name "Hello"
redis-cli-lua-script-exists:
redis-cli SCRIPT EXISTS c72b1fc2261c116957bbc839b558190a23d1cbb3
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-visualize:
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:
keydb-cli KEYS "*"
keydb-cli-set:
keydb-cli SET hm-name Hongbo
keydb-cli-get:
keydb-cli GET hm-name
keydb-cli-hmget:
keydb-cli HMGET trending-twitter-hashtags field1 field2
keydb-benchmark:
keydb-benchmark -a passw0rd
# KeyDB - multi-master
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-lua-script-load:
keydb-cli --pass passw0rd SCRIPT LOAD "$$(cat greet.lua)"
# KeyDB - Docker
keydb-docker-build:
cd ../.. && \
rm -f /tmp/cid.txt && \
docker create --cidfile=/tmp/cid.txt redislabs/redisgraph:latest && \
docker cp $$(cat /tmp/cid.txt):/usr/lib/redis/modules/redisgraph.so ./keydb/modules/ && \
docker container rm $$(cat /tmp/cid.txt) && \
rm -f /tmp/cid.txt && \
docker build --file=data-storage/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-multi-master:
docker run \
--detach \
--name=hm-keydb \
--publish=6379:6379 \
ghcr.io/hongbo-miao/hm-keydb:latest \
keydb-server \
/etc/keydb/keydb.conf \
--loadmodule /usr/lib/keydb/modules/redisgraph.so \
--multi-master yes \
--active-replica yes \
--replicaof 192.168.2.58 6379 \
--requirepass passw0rd \
--masterauth passw0rd
docker run \
--detach \
--name=hm-keydb \
--publish=6379:6379 \
ghcr.io/hongbo-miao/hm-keydb:latest \
keydb-server \
/etc/keydb/keydb.conf \
--loadmodule /usr/lib/keydb/modules/redisgraph.so \
--multi-master yes \
--active-replica yes \
--replicaof 192.168.2.117 6379 \
--requirepass passw0rd \
--masterauth passw0rd