A simple redis clone implemented in Clojure
You will need Leiningen 1.7.0 or above installed.
run:
lein deps
To start a web server for the application, run:
lein ring server
Send redis commands to http server by running: curl http://localhost:3000/api -d 'command=COMMAND-HERE'
Successful commands response begin with +OK
with optional message +OK message(optional)
Failed commands response begin with +ERR
with error message +ERR message
See below for commands supported
curl http://localhost:3000/api -d 'command=GET mykey'
--> +OK myval
# --> return the string value identified by key
curl http://localhost:3000/api -d 'command=SET mykey myval'
--> +OK
# --> Instantiate or overwrite a String identified by key with value value
curl http://localhost:3000/api -d 'command=DELETE mykey'
--> +OK
# --> Delete the String identified by key
curl http://localhost:3000/api -d 'command=LISTGET mykey'
--> +OK ["myval"]
# --> Return the List value identified by key
curl http://localhost:3000/api -d 'command=LISTSET mykey myval'
--> +OK
# --> Instantiate or overwrite a List identified by key with value value
curl http://localhost:3000/api -d 'command=LISTDELETE mykey'
--> +OK
# --> Delete the List identified by key
curl http://localhost:3000/api -d 'command=LISTAPPEND mykey myval2'
--> +OK
# --> Append a String value to the end of the List identified by key
curl http://localhost:3000/api -d 'command=LISTPOP mykey'
--> +OK
# --> Remove the last element in the List identified by key, and return that element.
curl http://localhost:3000/api -d 'command=MAPGET mykey'
--> +OK myval
# --> Return the Map value identified by key.
curl http://localhost:3000/api -d 'command=MAPSET mykey myval'
--> +OK
# --> Instantiate or overwrite a Map identified by key with value value
curl http://localhost:3000/api -d 'command=MAPDELETE mykey'
--> +OK
# --> Delete the Map identified by key
curl http://localhost:3000/api -d 'command=MAPMAPGET mykey mapkey'
--> +OK mapvalue
# --> Return the String identified by mapkey from within the Map identified by key
curl http://localhost:3000/api -d 'command=MAPMAPSET mykey mapkey mapvalue'
--> +OK
# --> Add the mapping mapkey -> mapvalue to the Map identified by key
curl http://localhost:3000/api -d 'command=MAPMAPDELETE mykey mapkey'
--> +OK
# --> Delete the value identified by mapkey from the Map identified by key
curl http://localhost:3000/api -d 'command=SEARCHKEYS string key'
--> +OK ["mykey"]
# --> Search string keys identified by query
curl http://localhost:3000/api -d 'command=SEARCHKEYS list key'
--> +OK ["mykey"]
# --> Search list keys identified by query
curl http://localhost:3000/api -d 'command=SEARCHKEYS map key'
--> +OK ["mykey"]
# --> Search map keys identified by query
run:
lein test miniredis-server.test.handler
Copyright © 2018 finixbit