Redis Client is a NoSQL key-value cache that stores information in a hash table format. It provides the possibilities to store different type of structured data like strings, hashes, lists, sets, sorted sets, bitmaps and hyperloglogs.
With Edge SDK 2.0 RedisClient functionality, developers can easily use Redis Server available on the gateway.
Namespace: Agora.Edge
The RedisClient is implemented as a singleton. The purpose of the RedisClient is to store, retrieve values from Redis Server.
{
"Name": "Sender",
"AEA2": {
"LogLevel": "Trace",
"RedisClient": {
"Server": "localhost",
"Port": 6379,
}
}
}Use the following command to connect to the Redis Server.
using System.Text.Json;
using static Agora.SDK;
internal class Program
{
private static void Main(string[] args)
{
"Starting".LogHeading();
Redis.Connect(2000);
}
}from agoraiot import *
redisclient = redisClientSingleton.connect(2)Use the following command to store and retrieve value.
using System.Text.Json;
using static Agora.SDK;
internal class Program
{
private static void Main(string[] args)
{
"Starting".LogHeading();
Redis.Connect(2000);
if (Redis.IsConnected)
{
//This one is used to store value
Redis.Client.StringSet("key", "value");
//This one is used to Get value
var value = Redis.Client.StringGet("key");
$"Value {value}".LogInfo();
}
}
}redisclient = redisClientSingleton.connect(2)
if redisclient.ping():
redisclient.set('my_key', 'my_value')
result = redisclient.get('my_key')
print(result)