Macrometa Tutorial: Redis As An Interface
Developers can use the Redis-like interface with the Macrometa platform
Redis is one of the most popular open-source in-memory data stores today, named the “Most Loved” database by Stack Overflow for five consecutive years. This year it lost that position to PostgreSQL.
Because of its fast performance, Redis is a popular choice for:
- Caching
- Gaming
- Leaderboards
- Chat/messaging apps
- Pub/sub apps
Developers can use the Redis commands with Macrometa and still automatically synchronize data between various locations worldwide in milliseconds.
It can interact with the Macrometa platform in various ways, using a console, an API call, or an SDK. Redis supports both JavaScript and Python SDK.
In the example below, we are using Python SDK to SET string key-value pairs:
from c8 import C8Client
client = C8Client(
protocol="https",
host="play.macrometa.io",
port=443,
apikey="xxxxx"
)
response = client.redis.set("test_key", "test_value", "test_redis")
print(response)
In our application we need to retrieve data, we can do that with GET Redis command as shown below:
from c8 import C8Client
client = C8Client(
protocol="https",
host="play.macrometa.io",
port=443,
apikey="xxxxx"
)
response = client.redis.get("test_key", "test_redis")
print(response)
In this case data is stored on the platform collection in this format:
{
"data_type": "string",
"expireDate": null,
"key": "fooString",
"value": "testValue"
}
Keep in mind that expireDate is an optional parameter.
See it in action in this brief video!
What are the benefits?
The Redis collection that we created is automatically synchronized across various locations around the world, up to over 175 locations. This leads to low latency times. Developers don’t need to worry about infrastructure and they can use well-known Redis commands they are already familiar with so there is no learning curve.
Get started today!
Check out the tutorials, QuickStart, and documentation to quickly get started with Macrometa. Sign up for a free developer account, or schedule a demo with one of our experts.