Skip to content

feat: add redis-caching #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alonexy
Copy link

@alonexy alonexy commented May 30, 2025

feat: Add Redis caching layer for policies
This commit introduces a Redis caching layer to the DBAL adapter to improve performance and reduce database load.

Features:

Policies loaded via loadPolicy and loadFilteredPolicy are now cached in Redis.
Configurable Redis connection parameters (host, port, password, database, TTL, prefix).
Automatic cache invalidation for the main policy cache (all_policies) when policies are modified.
A preheatCache() method to proactively load all policies into Redis.
The adapter remains fully functional if Redis is not configured.
Includes:

Updates to Adapter.php to integrate caching logic.
Addition of predis/predis as a dependency.
Unit tests for the caching functionality in AdapterWithRedisTest.php.
Documentation in README.md for the new feature.
Known limitations:

Cache invalidation for loadFilteredPolicy currently only clears the global all_policies key, not specific filtered policy keys, to avoid using KEYS in production with Predis.

@leeqvip
Copy link
Member

leeqvip commented May 31, 2025

@alonexy Please fix test error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants