pmeinhardt / redis-functions

Tiny modules for extending Redis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redis Functions

luacheck tests

A collection of modules to extend Redis with additional functions.

Usage

To load functions bundled in a module, run:

cat module.lua | redis-cli -x FUNCTION LOAD REPLACE

To list available functions:

redis-cli FUNCTION LIST [LIBRARYNAME library-name-pattern]

To invoke a function:

redis-cli FCALL function-name number-of-keys [key ...] [arg ...]

Example:

cat modules/hello.lua | redis-cli -x FUNCTION LOAD REPLACE

redis-cli FCALL hello 0
# "Hello, World!"

redis-cli FCALL hello 0 Redis
# "Hello, Redis!"

For more information on function-related commands, check out the official Redis docs.

Background

Redis supports persisted and replicated custom functions in versions 7.0 and newer. Functions are useful for maintaining a consistent view onto your data through a logical schema. They are (at present) written in Lua, using Redis’ Lua API.

If you are tied to an older version of Redis, you might still be able to re-use code from these modules via Redis scripting.

If you need low-level access or more fine-grained control, take a look at the Redis Modules API.

About

Tiny modules for extending Redis

License:MIT License


Languages

Language:Lua 96.7%Language:Shell 3.3%