Skip to content

Sidfate/MyRedisModules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MyRedisModules

This repository is forked from RedisModulesSDK.

The Redis 4.x has the feature of Modules.Modules allow us to implement new Redis commands at a speed and with features similar to what can be done inside the core itself.

In this repository, I implement some customized commands in file example/module.c.

Platform

  • Redis version >= 4.0.0
  • Linux | MacOS
  • C

Startup

  1. Make the module.so.
$ git clone [email protected]:Sidfate/MyRedisModules.git
$ cd ./MyRedisModules/example
$ make all
  1. Start redis server with module.so.
$ /path/to/redis-server --loadmodule ./module.so
  1. Test for command
$ redis-cli
127.0.0.1:6379> MY.TEST
PASS

Commands

  1. MY.HGETSET

    This command extends from RedisModulesSDK.

    Atomically set a value in a HASH key to and return its value before the HSET.

    Usage:

    MY.HGETSET <key> <element> <value>
    

    Test:

    $ redis-cli
    127.0.0.1:6379> MY.HGETSET foo bar baz
    (nil)
    127.0.0.1:6379> MY.HGETSET foo bar vaz
    "baz"
  2. MY.LDEL

    Delete list element by the index

    Usage:

    MY.LDEL <key> <index>
    

    Test:

    $ redis-cli
    127.0.0.1:6379> RPUSH mylist "test1"
    (integer) 1
    127.0.0.1:6379> RPUSH mylist "test2"
    (integer) 2
    127.0.0.1:6379> RPUSH mylist "test1"
    (integer) 3
    127.0.0.1:6379> LRANGE mylist 0 -1
    1) "test1"
    2) "test2"
    3) "test1"
    127.0.0.1:6379> MY.LDEL mylist 0
    OK
    127.0.0.1:6379> LRANGE mylist 0 -1
    1) "test2"
    2) "test1"

License

MIT

About

My redis modules for more useful command.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published