The library is quite limited in functionality compared to redis-py, but it offers extensive functionality if you need a minimal set of commands for working with a database. If you need additional functionality, use the redis_py() function, which returns an object from the original library.
pip install pyluaredis
How does this library differ from redis-py, on which it is built?
For quick connection to your Python projects and easy usage. «Plug and Play» :)
- The methods have a more flexible type system, you can get both a number and a list using one r_get function, without worrying about what exactly is being treated in a given key.
- Scenarios that require 2 or more calls to the Redis service are built on the basis of Lua scripts that perform all operations in 1 call to the server.
- The methods have additional parameters that are not in the standard library, for example, an analogue of RETURNING (like in Postgres), which also allows you not to worry about the type of the variable that lies in a given key.
- It helps in the development of applications following the 12-factor principles.
- It is assumed that you already have the Redis service installed and running.
- There is no need to install Lua as it is built into Redis.
But, .lua scripts are cached within a single class object and subsequent function calls will be faster (almost the same time as the original implementation).
You can see comparisons with the original library in the file benchmark/main.py This library is not about the speed of working with Redis, it is about the ease of working with Redis, allowing you to not worry about a lot of different functions of the database and the original library, as well as data types.
Supported Python types:
- integer
- float
- string
- boolean
- bytes
- list
- tuple
- set
- frozenset
The number of supported methods and data types increases as the project develops, but it has all the basic methods for working with Redis (see the list and description of current commands with examples in the example.py file in the root of the repository).
Backward compatibility of functions is also maintained (from versions >= 2.0), which allows you to avoid problems when using the library in your projects.
