![[FREE] RedisFX: a Redis resource for FXServer.](/_next/image?url=https%3A%2F%2Fforum-cfx-re.akamaized.net%2Foptimized%2F5X%2F1%2F3%2Fd%2F1%2F13d1ac72825ff29c964e524bd3418e87fee8aa2f_2_690x255.png&w=2048&q=75)
von m3ftwz
This project was forked from CommunityOx’s oxmysql and adapted to use Redis instead of MySQL.
A FiveM resource providing Redis connectivity for game server scripts using node-redis. It serves as a bridge between your FiveM resources and a Redis database, offering both synchronous and asynchronous APIs.
github.comNote: The full, most recent documentation can be found in the Github README.
Add the following to your fxmanifest.lua to enable type-checking and intellisense:
server_script '@redisfx/lib/Redis.lua'
Then use in your scripts:
-- String commands
local name = Redis.get.await('player:1:name')
Redis.set('player:1:name', 'John', { EX = 3600 }) -- expires in 1 hour
-- Hash commands
Redis.hset('player:1', 'money', 1000)
local money = Redis.hget.await('player:1', 'money')
local player = Redis.hgetall.await('player:1')
-- List commands
Redis.lpush('queue', 'job1')
local job = Redis.lpop.await('queue')
-- Set commands
Redis.sadd('online', 'player:1')
local isOnline = Redis.sismember.await('online', 'player:1')
-- Sorted sets (leaderboards)
Redis.zadd('leaderboard', 100, 'player:1')
local top10 = Redis.zrange.await('leaderboard', 0, 9)