Skip to content

if-nil/ReApi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReAPI logo

English | 中文

Redis HTTP API Module (ReAPI)

A Redis module that provides HTTP interfaces to access Redis commands. It allows interaction with Redis through RESTful APIs, making it convenient for non-Redis clients to communicate with Redis.

Features

  • HTTP interface for Redis commands
  • JSON formatted responses
  • Support for all Redis commands
  • Built-in Web interface
  • Lightweight and easy to deploy

Installation

  1. Make sure your Redis supports modules
  2. Build the module:
cargo build --release
  1. Load the module into Redis:
redis-server --loadmodule /path/to/libreapi.so

Configuration Parameters

When loading the module, you can specify the following parameters:

redis-server --loadmodule /path/to/libreapi.so reapi_host 127.0.0.1 reapi_port 9098
Parameter Description Default Value
reapi_host The host address that ReAPI server will bind to 127.0.0.1
reapi_port The port number that ReAPI server will listen on 9098

Usage Examples

HTTP API

# Set key-value in default database (DB 0)
curl http://127.0.0.1:9098/set/mykey/hello
{"result":"OK"}

# Set key-value in database 1
curl http://127.0.0.1:9098/1/set/mykey/hello
{"result":"OK"}
# Get value from default database (DB 0)
curl http://127.0.0.1:9098/get/mykey
{"result":"hello"}

# Get value from database 1
curl http://127.0.0.1:9098/1/get/mykey
{"result":"hello"}
# Execute other Redis commands
curl http://127.0.0.1:9098/hset/myhash/field1/value1

Web Interface

Visit http://127.0.0.1:9098 to use the built-in web console. You can:

  • Input Redis commands in the command line
  • Select database (DB 0-15) from the dropdown menu
  • Execute commands and see results in real-time