How To Install lua-resty-lrucache on Debian 12

Learn how to install lua-resty-lrucache on Debian 12 with this tutorial. lua-resty-lrucache is Simple LRU cache for the ngx_lua module

Introduction

In this tutorial we learn how to install lua-resty-lrucache on Debian 12.

What is lua-resty-lrucache

lua-resty-lrucache is:

The LRU cache resides completely in the Lua VM and is subject to Lua GC. As such, do not expect it to get shared across the OS process boundary. The upside is that you can cache arbitrary complex Lua values (such as deep nested Lua tables) without the overhead of serialization (as with ngx_lua’s shared dictionary API). The downside is that your cache is always limited to the current OS process (i.e. the current Nginx worker process). It does not really make much sense to use this library in the context of init_by_lua because the cache will not get shared by any of the worker processes (unless you just want to “warm up” the cache with predefined items which will get inherited by the workers via fork()).

There are three methods to install lua-resty-lrucache on Debian 12. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install lua-resty-lrucache Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install lua-resty-lrucache using apt-get by running the following command:

sudo apt-get -y install lua-resty-lrucache

Install lua-resty-lrucache Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install lua-resty-lrucache using apt by running the following command:

sudo apt -y install lua-resty-lrucache

Install lua-resty-lrucache Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install lua-resty-lrucache using aptitude by running the following command:

sudo aptitude -y install lua-resty-lrucache

How To Uninstall lua-resty-lrucache on Debian 12

To uninstall only the lua-resty-lrucache package we can use the following command:

sudo apt-get remove lua-resty-lrucache

Uninstall lua-resty-lrucache And Its Dependencies

To uninstall lua-resty-lrucache and its dependencies that are no longer needed by Debian 12, we can use the command below:

sudo apt-get -y autoremove lua-resty-lrucache

Remove lua-resty-lrucache Configurations and Data

To remove lua-resty-lrucache configuration and data from Debian 12 we can use the following command:

sudo apt-get -y purge lua-resty-lrucache

Remove lua-resty-lrucache configuration, data, and all of its dependencies

We can use the following command to remove lua-resty-lrucache configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge lua-resty-lrucache

Dependencies

lua-resty-lrucache have the following dependencies:

References

Summary

In this tutorial we learn how to install lua-resty-lrucache package on Debian 12 using different package management tools: apt, apt-get and aptitude.