Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
d02fb5c
feat(cache): implement caching system with Valkey and in-memory backends
kzndotsh Jan 28, 2026
fbbbfb2
docs(caching): update caching best practices and environment variable…
kzndotsh Jan 28, 2026
69c6300
feat(env): add Valkey configuration options and update example files
kzndotsh Jan 28, 2026
dacb7fc
feat(health): add Valkey health check to database health command
kzndotsh Jan 28, 2026
6f48a1c
feat(cache): implement CacheSetupService for Valkey integration
kzndotsh Jan 28, 2026
ce2a1a0
feat(cache): integrate CacheService for Valkey connection management
kzndotsh Jan 28, 2026
31d9e99
refactor(permission_system): switch to cache backend for command perm…
kzndotsh Jan 28, 2026
ef889e8
feat(prefix_manager): integrate cache backend for prefix management
kzndotsh Jan 28, 2026
cb02d66
feat(database): integrate cache backend for database controllers
kzndotsh Jan 28, 2026
555d582
refactor(moderation): update JailStatusCache usage for async operations
kzndotsh Jan 28, 2026
61cbc6c
refactor(comm_service): update guild config cache methods for async s…
kzndotsh Jan 28, 2026
3ded370
feat(config): add Valkey configuration options to settings
kzndotsh Jan 28, 2026
cacda70
refactor(cache): remove TTLCache implementation and update shared module
kzndotsh Jan 28, 2026
da62e83
feat(tests): add comprehensive unit tests for cache functionality
kzndotsh Jan 28, 2026
7e67236
docs(agents): update documentation to include Valkey cache integration
kzndotsh Jan 28, 2026
216e0c5
chore(dependencies): add Valkey as a new dependency
kzndotsh Jan 28, 2026
7d38f7b
feat(docker): add Valkey service to Docker Compose configuration
kzndotsh Jan 28, 2026
6c630d6
docs(agents): update Valkey usage instructions in Docker Compose docu…
kzndotsh Jan 29, 2026
0008534
feat(docker): add profile configuration for Valkey service in Docker …
kzndotsh Jan 29, 2026
4552714
feat(security): enhance Valkey password validation and URL encoding
kzndotsh Jan 29, 2026
0c6b182
refactor(cache): update AsyncCacheBackend methods and enhance InMemor…
kzndotsh Jan 29, 2026
e1c08d8
refactor(cache): enhance concurrency handling in GuildConfigCacheManager
kzndotsh Jan 29, 2026
d99695d
refactor(cache): update Valkey client initialization logging
kzndotsh Jan 29, 2026
24663fd
feat(cache): add method to invalidate cache entries by key predicate
kzndotsh Jan 29, 2026
8c23b72
fix(health): improve Valkey health check logging
kzndotsh Jan 29, 2026
9ae1a0b
fix(bot): enhance error logging for cache disconnection
kzndotsh Jan 29, 2026
a5be0a7
refactor(permission): remove unused in-memory cache from PermissionSy…
kzndotsh Jan 29, 2026
a9abd3c
docs(prefix_manager): clarify cache invalidation behavior in document…
kzndotsh Jan 29, 2026
26b6764
refactor(tests): streamline test setup and improve clarity in assertions
kzndotsh Jan 29, 2026
d4cc00e
test(cache): add unit tests for CacheSetupService initialization and …
kzndotsh Jan 29, 2026
ec85cc9
refactor(cache): add placeholder implementation for exists method in …
kzndotsh Jan 29, 2026
3ecc80c
test(cache): add comprehensive unit tests for GuildConfigCacheManager…
kzndotsh Jan 29, 2026
6ccb6e1
test(cache): add unit tests for TTLCache functionality
kzndotsh Jan 29, 2026
e435d39
test(permission): add unit tests for PermissionSetupService setup logic
kzndotsh Jan 29, 2026
3b2ce42
test(prefix_manager): add unit tests for PrefixManager functionality
kzndotsh Jan 29, 2026
a362839
test(permissions): add unit tests for PermissionRankController with c…
kzndotsh Jan 29, 2026
e1397d9
test(config): add unit tests for valkey_url configuration logic
kzndotsh Jan 29, 2026
07bd082
fix(cache): add type ignore comment for exists method in AsyncCacheBa…
kzndotsh Jan 29, 2026
a8bf37c
docs(caching): update async_set description for JailStatusCache
kzndotsh Jan 29, 2026
f6a3704
fix(cache): update JSON serialization in ValkeyBackend
kzndotsh Jan 29, 2026
f0fa68e
feat(cache): enhance GuildConfigCacheManager with locking and null lo…
kzndotsh Jan 29, 2026
6ed1973
feat(cache): improve TTLCache eviction logic and handle None values
kzndotsh Jan 29, 2026
1e09113
refactor(permission_system): optimize cache retrieval and storage wit…
kzndotsh Jan 29, 2026
89ce8b3
refactor(prefix_manager): enhance cache invalidation logic for guild …
kzndotsh Jan 29, 2026
de48ccc
refactor(test): update async_set test to reflect overwriting behavior…
kzndotsh Jan 29, 2026
47f579b
test(cache): add test for get_or_fetch behavior with None values
kzndotsh Jan 29, 2026
3d3c537
refactor(test): update prefix_manager fixture to use generator for be…
kzndotsh Jan 29, 2026
519988b
refactor(test): enhance environment setup for deterministic configura…
kzndotsh Jan 29, 2026
cbc8e8a
docs(caching): update cache key naming and method calls for clarity
kzndotsh Jan 29, 2026
4175a00
fix(cache): handle _CACHED_NONE in TTLCache to prevent unnecessary re…
kzndotsh Jan 29, 2026
4f736a8
fix(permission_system): improve cache handling for command permissions
kzndotsh Jan 29, 2026
4feac23
refactor(prefix_manager): optimize prefix cache writing and deletion …
kzndotsh Jan 29, 2026
527b554
refactor(test): update cache fixtures to use generators for improved …
kzndotsh Jan 29, 2026
b97cbd2
test(prefix_manager): enhance test coverage for prefix retrieval and …
kzndotsh Jan 29, 2026
5c2aee1
fix(permission_system): streamline cache handling for command permiss…
kzndotsh Jan 29, 2026
1a8680e
docs(caching): clarify backend-specific cache behavior and operationa…
kzndotsh Jan 29, 2026
675443d
docs(configuration): add Valkey cache options and clarify bot owner s…
kzndotsh Jan 29, 2026
0bc4157
fix(logging): update logger messages in cache managers for improved c…
kzndotsh Jan 29, 2026
1c247c0
fix(logging): correct logger message formatting in cache setup
kzndotsh Jan 29, 2026
09b19bb
fix(compose): change Valkey server log level from warning to debug
kzndotsh Jan 29, 2026
e70655f
docs(environment): clarify Valkey host configuration for local and Do…
kzndotsh Jan 29, 2026
3d497e2
docs(caching): expand Cache TTL reference and clarify backend behavior
kzndotsh Jan 29, 2026
4882f5c
refactor(jail): optimize database queries for jail configuration
kzndotsh Jan 29, 2026
3f76704
refactor(moderation): improve case creation and DM handling in modera…
kzndotsh Jan 29, 2026
1335479
fix(cache): ensure proper service closure in CacheSetupService
kzndotsh Jan 29, 2026
638381f
refactor(cache): enhance cache setup documentation and logging
kzndotsh Jan 29, 2026
92dacf2
refactor(cache): enhance docstrings for cache managers
kzndotsh Jan 29, 2026
9c74b36
docs(environment): enhance Valkey configuration instructions for loca…
kzndotsh Jan 29, 2026
d1df808
fix(compose): change Valkey server log level from debug to warning
kzndotsh Jan 29, 2026
873ed68
docs(caching): clarify Valkey TTL handling in caching documentation
kzndotsh Jan 29, 2026
6a9c5d7
refactor(cache): remove unused _null_lock method from GuildConfigCach…
kzndotsh Jan 29, 2026
267c91c
refactor(prefix_manager): specify type for write_tasks in PrefixManager
kzndotsh Jan 29, 2026
5b40862
refactor(jail): update cache invalidation and add cooldown to jail co…
kzndotsh Jan 29, 2026
83270ef
refactor(moderation): improve type safety in moderation coordinator
kzndotsh Jan 29, 2026
9041ce5
chore(changelog): update CHANGELOG for recent enhancements and fixes
kzndotsh Jan 29, 2026
bd2c943
refactor(moderation): enhance exception handling in moderation coordi…
kzndotsh Jan 29, 2026
5de958b
fix(prefix_manager): improve error handling for prefix caching
kzndotsh Jan 29, 2026
ae2eebf
fix(cache): improve error handling in ValkeyBackend
kzndotsh Jan 29, 2026
d5d2675
fix(database_setup): improve current revision retrieval and logging
kzndotsh Jan 29, 2026
4cfcb0e
feat(permission_checks): implement dynamic permission checks for comm…
kzndotsh Jan 29, 2026
974cff1
feat(permission_checks): add command permission check function
kzndotsh Jan 29, 2026
78162bc
feat(permission_system): add cache invalidation method for command pe…
kzndotsh Jan 29, 2026
43c2606
feat(permission_system): implement command permission cache invalidation
kzndotsh Jan 29, 2026
257987b
refactor(moderation): simplify type handling in moderation coordinator
kzndotsh Jan 29, 2026
739b0c7
feat(exceptions): enhance permission error messaging for unconfigured…
kzndotsh Jan 29, 2026
339aced
feat(permission_system): enhance role and command permission handling
kzndotsh Jan 29, 2026
a630f23
refactor(permission_system): update role removal logic for cache inva…
kzndotsh Jan 29, 2026
f6b30ae
fix(cache_setup): ensure proper closure of cache service on connectio…
kzndotsh Jan 29, 2026
910fddc
fix(decorators): replace contextlib with try-except for interaction d…
kzndotsh Jan 29, 2026
dd720fe
refactor(permission_system): extract cache invalidation logic into a …
kzndotsh Jan 29, 2026
ac33c01
refactor(database): add cache backend support to CaseController initi…
kzndotsh Jan 29, 2026
47c50b7
refactor(database): implement caching for case retrieval in CaseContr…
kzndotsh Jan 29, 2026
d960f2d
feat(permissions): add role assignment removal method and enhance cac…
kzndotsh Jan 29, 2026
552e205
refactor(permission_system): optimize role removal logic for cache in…
kzndotsh Jan 29, 2026
6f49386
fix(snippets): improve snippet ban check logic
kzndotsh Jan 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(moderation): update JailStatusCache usage for async operations
- Modified JailStatusCache calls in the jail and unjail modules to use async methods for cache invalidation, ensuring proper handling of asynchronous operations.
- Cleaned up import statements to consistently use the new cache import path across modules.
- Updated validation checks in utility functions for improved clarity and type safety.
  • Loading branch information
kzndotsh committed Jan 28, 2026
commit 555d582dd1f0effeea3d8923d12acc9dab2fc58e
2 changes: 1 addition & 1 deletion src/tux/modules/info/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
raise ValueError(error_msg)
super().__init__(timeout=timeout)
self.items = list(items)
self.chunks_list: list[list[str]] = list(chunks(iter(self.items), chunk_size))
self.chunks_list = list(chunks(iter(self.items), chunk_size))
self.current_page = 0
self.title = title
self.list_type = list_type
Expand Down
2 changes: 1 addition & 1 deletion src/tux/modules/moderation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import discord
from discord.ext import commands

from tux.cache import JailStatusCache
from tux.core.base_cog import BaseCog
from tux.core.bot import Tux
from tux.database.models import CaseType as DBCaseType
from tux.services.moderation import ModerationServiceFactory
from tux.shared.cache import JailStatusCache

if TYPE_CHECKING:
from tux.services.moderation import ModerationCoordinator
Expand Down
6 changes: 3 additions & 3 deletions src/tux/modules/moderation/jail.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
from discord.ext import commands
from loguru import logger

from tux.cache import JailStatusCache
from tux.core.bot import Tux
from tux.core.checks import requires_command_permission
from tux.core.flags import JailFlags
from tux.database.models import CaseType
from tux.shared.cache import JailStatusCache

from . import ModerationCogBase

Expand Down Expand Up @@ -128,7 +128,7 @@ async def on_member_join(self, member: discord.Member) -> None:
f"Re-jailed {member} on rejoin in guild {member.guild.id} ({member.guild.name})",
)
# Invalidate jail status cache (should already be True, but ensure consistency)
JailStatusCache().set(member.guild.id, member.id, True)
await JailStatusCache().set(member.guild.id, member.id, True)
# Strip roles added by other on_member_join handlers (e.g. TTY roles ~5s)
asyncio.create_task( # noqa: RUF006
self._delayed_rejail_cleanup(member.guild.id, member.id),
Expand Down Expand Up @@ -263,7 +263,7 @@ async def jail(
)

# Invalidate jail status cache after jailing
JailStatusCache().invalidate(ctx.guild.id, member.id)
await JailStatusCache().invalidate(ctx.guild.id, member.id)

# Remove old roles in the background after sending the response
# Use graceful degradation - if some roles fail, continue with others
Expand Down
4 changes: 2 additions & 2 deletions src/tux/modules/moderation/unjail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from discord.ext import commands
from loguru import logger

from tux.cache import JailStatusCache
from tux.core.bot import Tux
from tux.core.checks import requires_command_permission
from tux.core.flags import UnjailFlags
from tux.database.models import Case
from tux.database.models import CaseType as DBCaseType
from tux.shared.cache import JailStatusCache

from . import ModerationCogBase

Expand Down Expand Up @@ -250,7 +250,7 @@ async def perform_unjail() -> None:

# Invalidate jail status cache after unjailing
assert ctx.guild is not None
JailStatusCache().invalidate(ctx.guild.id, member.id)
await JailStatusCache().invalidate(ctx.guild.id, member.id)

# Execute the action (removed lock since moderation service handles concurrency)
await perform_unjail()
Expand Down
4 changes: 2 additions & 2 deletions src/tux/modules/utility/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ async def del_afk(
AttributeError
If target is not a Member or doesn't have a guild attribute.
"""
# Validate that target is a Member with a guild
if not isinstance(target, discord.Member) or target.guild is None:
# Validate that target is a Member with a guild (runtime check for callers)
if not isinstance(target, discord.Member) or target.guild is None: # type: ignore[reportUnnecessaryIsInstance, reportUnnecessaryComparison]
msg = f"target must be a discord.Member with a guild, got {type(target)}"
raise AttributeError(msg)

Expand Down