Redis is an in-memory data store, used as a database, cache, and message broker. It supports various data structures such as strings, hashes, lists, sets, and more, offering high performance and wide-ranging versatility. You can find more information about this great database at https://redis.io.
The Acornfile used to create a Redis based Acorn Service is available in the GitHub repository at https://github.com/acorn-io/redis. This service triggers the creation of a Redis database running in a single container which can easily be used by an application during development.
This Redis instance:
Currently this Acorn does not have any configuration options, but some will be added later on like:
The examples folder https://github.com/acorn-io/redis/tree/main/examples contains a sample application using this Service. This app consists of a Python backend based on the FastAPI library, it displays a web page indicating the number of times the application was called, a counter is saved in the underlying Redis database and incremented with each request. The screenshot below shows the UI of the example application.
To use the Redis Service, we first define a service property in the Acornfile of the application. This one references the image of the Redis Acorn.
Next we define the application container:
This container is built using the Dockerfile in the examples folder. Once built, the container consumes the Redis service using the address and admin password provided through dedicated variables:
This example can be run with the following command (to be run from the examples folder)
After a few tens of seconds an http endpoint will be returned. Using this endpoint we can access the application and see the counter incremented on each reload of the page.
Instead of managing your own Acorn installation, you can deploy this application in the Acorn Sandbox, the free SaaS offering provided by Acorn. Access to the sandbox requires only a GitHub account, which is used for authentication.
An application running in the Sandbox will automatically shut down after 2 hours, but you can use the Acorn Pro plan to remove the time limit and gain additional functionalities.