
Product
Introducing Scala and Kotlin Support in Socket
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
A utility package for managing Redis keys in Python. This package provides an easy-to-use interface for interacting with Redis, including setting, getting, and managing expiration of keys.
You can install this package directly from GitHub:
pip install git+https://github.com/AAbbasRR/redis-manager.git
Alternatively, clone the repository and install manually:
git clone https://github.com/AAbbasRR/redis-manager.git
cd my_redis_utils
pip install .
By default, the package uses localhost
and the default Redis port (6379). You can configure the Redis connection
using python-decouple
or by providing the parameters directly.
REDIS_HOST
: The hostname or IP address of the Redis server. Default is localhost
.REDIS_PORT
: The port number on which the Redis server is listening. Default is 6379
.REDIS_DB
: The Redis database number to use. Default is 0
.FERNET_KEY
: Before using the application, it's essential to set up the FERNET_KEY
. This key is used for encrypting
and decrypting sensitive data.python-decouple
Install python-decouple
:
pip install python-decouple
Create a .env
file in your project root and add your Redis configuration:
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_DB=0
FERNET_KEY=YourGeneratedKeyHere
Use the configuration in your code:
from redis_management.redis_manager import RedisManager
redis_manager = RedisManager(identifier="user123", key="session_token")
To generate a FERNET_KEY
, you can use the following command in your terminal:
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
from redis_management.redis_manager import RedisManager
redis_manager = RedisManager(identifier="user123", key="session_token")
redis_manager.set_value("some_value")
value = redis_manager.get_value()
print(value)
redis_manager.set_json_value({"key": "value"})
json_value = redis_manager.get_json_value()
print(json_value)
otp_code = redis_manager.create_and_set_otp_key()
print(otp_code)
is_valid = redis_manager.validate(otp_code)
print(is_valid)
exists = redis_manager.exists()
print(exists)
redis_manager.delete()
The package provides custom exceptions for better error handling:
RedisException
: Base exception for Redis errors.KeyNotFoundException
: Raised when a key is not found in Redis.InvalidKeyException
: Raised when an invalid key is provided.Example:
from redis_management.redis_manager import RedisManager
from redis_management.exceptions import KeyNotFoundException
try:
redis_manager = RedisManager(identifier="user123", key="non_existent_key")
value = redis_manager.get_value()
except KeyNotFoundException:
print("Key not found in Redis.")
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
Abbas Rahimzadeh - arahimzadeh79@gmail.com
Special thanks to the open-source community for their valuable contributions and resources.
FAQs
A utility package for managing Redis keys.
We found that redis-management demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.
Application Security
/Security News
Socket CEO Feross Aboukhadijeh and a16z partner Joel de la Garza discuss vibe coding, AI-driven software development, and how the rise of LLMs, despite their risks, still points toward a more secure and innovative future.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.