Skip to content

Latest commit

 

History

History
64 lines (58 loc) · 2.19 KB

Redis.mkd

File metadata and controls

64 lines (58 loc) · 2.19 KB

Redis Support

Description

We've added the support for Redis, this is a database that works with key-value, it's very fast and it's used for cache, we've added the support for this database because it's very useful for some things like save in memory data that need to be accessed very fast.

Use

To use this feature you need to enable the Config.Redis option in the config.js file, then you have to provide the redis credentials in the server.cfg file like this:

set redisCredentials "redis://user:password@127.0.0.1:6379/0"

When the server start if the credentials are correct the resource will connect to the database and it will be ready to use. Functions List:

Redis.Get(key, callback);
Redis.Set(key, values, callback);
Redis.Del(key, callback);
Redis.Exist(key, callback);
Redis.Expire(key, seconds, callback);
Redis.Update(key, value, callback);
Redis.Flush(callback);
Redis.Keys(pattern, callback);
Redis.MGet(keys, callback);
Redis.Close();
Redis.Open();
Redis.Reload();

Params

  • key/s(*) is the key or keys that you want to use in the query, if you want to use more than one key you have to use an array of keys.
  • values(depending) is the value or values that you want to set in an entry, if you want to use more than one value you have to use an array of values.
  • callback(optional) is the function that will be called when the data or function is finished, if the callback is not specified the query will be executed and it will be as an await function.

Examples

Set
local result = exports["icmysql"]:RedisSet("name", "Daniel");
-- OK
Update
local result = exports["icmysql"]:RedisUpdate("name", "Daniel3");
-- OK
Get
local result = exports["icmysql"]:RedisGet("name");
-- Daniel3
Delete
local result = exports["icmysql"]:RedisDel("name");
-- OK
Flush
local result = exports["icmysql"]:RedisFlush();
-- OK

Files

This is the list of the involved files in this feature to help any developer to understand how it works:

  • src/db/redis/index.js