跳到主要内容

Redis

Redis in Illa is a database integration that allows you to connect and interact with a Redis database. Redis is a popular open-source relational database management system that is known for its speed, reliability, and ease of use.

With the Redis integration in Illa, you can query, insert, update, and delete data from a Redis database using SQL commands. You can also create custom SQL queries and run them within Illa. This makes it easy to build data-driven applications and dashboards that display real-time data from a Redis database.

Create Redis

There are two ways to create a resource in Illa after signing into your Illa account.

  • Create in Resources

Sign into your Illa account, select **Resources** on the top of the page, and click **Create New** button.

external_resource

Select Redis from the database list.

action_list

Connect to the database with the required parameters described in Connection Settings below.

Click **Test Connection** to see if we can successfully connect to the database. If yes, click Save Resources, else, double check the hostname, port, username, and password is correct.

After creating a resource, the ready Redis will display as shown.

redis_ex_ready

  • Create in Builder

Sign into your Illa account, create a project in Illa Builder in the **App** page, and navigate to the Action List at the bottom of the page. Click **new**, then select Redis from the database list. Then, connect to the database with required parameters described in Connection Settings below.

Click **Test Connection** to see if we can successfully connect to the database. If yes, click Save Resources, else, double check the hostname, port, username, and password is correct.

Connection Settings

Here we need to provide information for connecting to Redis database.

redis_config

PropertiesRequiredDescription
NamerequiredThe name for resource when creating actions in the ILLA.
HostnamerequiredThe URL or IP address for your database
PortrequiredThe server host's port number that you should use to connect. If you don't specify a port, the default port is '6379'.
Database Indexoptionala data structure that is used to optimize the performance of queries that retrieve data from a Redis database
DatabaserequiredThe name of the database
Usernamerequiredthe username you wish to use when logging in to the Redis server.
PasswordrequiredUse this password for authentication.
SSL optionsoptionaldecides how high a secure SSL TCP/IP connection is prioritized while negotiating with the server.

Create Actions

We have created a Redis resource, we can add the action by selecting Redis from action list and choosing the Create action button.

redis_resource_list

Now we have added the Redis server as an action to our building page.

redis

Configure Redis

PropertiesDescription
querycommands to retrieve data from database
Transformertransforming data into the style you like using JavaScript

Example usage:

  • KEYS

This command retrieves a list of all keys in the Redis database. You can use wildcards to filter the keys by pattern.

KEYS *
KEYS user:*
  • GET

This command retrieves the value associated with a given key.

GET user:12345
  • HGETALL

This command retrieves all fields and their values from a Redis hash data structure.

HGETALL user:12345
  • ZRANGE

This command retrieves a range of values from a Redis sorted set data structure, based on their scores.

ZRANGE high_scores 0 9 WITHSCORES
  • LRANGE

This command retrieves a range of values from a Redis list data structure.

LRANGE my_list 0 4
  • EXISTS

This command checks if a given key exists in the Redis database.

EXISTS user:12345
  • TTL

This command retrieves the time-to-live (TTL) value associated with a key, which specifies how long the key will remain in the database before it expires.

TTL user:12345