added README

master
Dvir Volk 9 years ago
parent c396da1f2a
commit a0517aadb2

@ -1,10 +1,71 @@
# RedisModulesSDK # RedisModulesSDK
Tools, utilities and scripts to help you write redis modules!
This little repo is here to help you write redis modules a bit more easily.
## What will be here
* helper utilities that aren't part of the API. ## What it includes:
* testing framework
* module project template (makefile, bootstrapped project, etc) ### redismodule.h
* VSCode integration config files.
* Documentation The only file you really need to start writing Redis modules. Either put this path into your module's include path, or copy it.
* anything else? :)
Notice: The original file is in the Redis repo, this is an up to date copy of it.
### LibRMUtil
A small library of utility functions and macros for module developers, Including:
* Easier argument parsing for your commands.
* Testing utilities that allow you to wrap your module's tests as a redis command.
* `RedisModuleString` utility functions (formatting, comparison, etc)
* The entire `sds` string library, lifted from Redis itself.
* A generic scalable Vector library. Not redis specific but we found it useful.
* A few other helpful macros and functions.
It can be found under the `rmutil` folder, and compiles into a static library you link your module against.
### An example Module
A minimal module implementing a few commands and demonstarting both the Redis Module API, and use of rmutils.
You can treat it as a template for your module, and extned its code and makefile.
**It includes 3 commands:**
* `EXAMPLE.PARSE` - demonstrating rmutil's argument helpers.
* `EXAMPLE.HGETSET` - an atomic HGET/HSET command, demonstrating the higher level Redis module API.
* `EXAMPLE.TEST` - a unit test of the above commands, demonstrating use of the testing utilities of rmutils.
### Documentation Files:
1. [API.md](API.md) - The official manual for writing Redis modules, copied from the Redis repo.
Read this before starting, as it's more than an API reference.
2. [FUNCTIONS.md](FUNCTIONS.md) - Generated API reference documentation for both the Redis module API, and LibRMUtil.
## Quick Start
Here's what you need to do to build your first module:
0. Build Redis in a build supporting modules.
1. Build librmutil: `cd rmutil && make`
2. Build the example module: `cd example && make`
3. Run redis loading the module: `/path/to/redis-server --loadmodule ./example/module.so`
Now run `redis-cli` and try the commands:
```
127.0.0.1:9979> EXAMPLE.HGETSET foo bar baz
(nil)
127.0.0.1:9979> EXAMPLE.HGETSET foo bar vaz
"baz"
127.0.0.1:9979> EXAMPLE.PARSE SUM 5 2
(integer) 7
127.0.0.1:9979> EXAMPLE.PARSE PROD 5 2
(integer) 10
127.0.0.1:9979> EXAMPLE.TEST
PASS
```
Enjoy!
Loading…
Cancel
Save