From ecfde46f9432b571aca4d0152706af22cc5ffbec Mon Sep 17 00:00:00 2001 From: Renovate Date: Wed, 30 Apr 2025 18:21:41 +0300 Subject: [PATCH 1/8] Update dependency redis to ~=5.3.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 0cd2539..fadbec3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,6 @@ async_pymongo==0.1.11 libbot[speed,pycord,cache]==4.1.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 -redis~=5.2.1 +redis~=5.3.0 ujson~=5.10.0 WaifuPicsPython==0.2.0 \ No newline at end of file -- 2.39.5 From 42cc6aa29e50547e3014a5e9236c1fca25e9ca6f Mon Sep 17 00:00:00 2001 From: Renovate Date: Wed, 30 Apr 2025 22:28:12 +0300 Subject: [PATCH 2/8] Update dependency redis to v6 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index fadbec3..306475d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,6 @@ async_pymongo==0.1.11 libbot[speed,pycord,cache]==4.1.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 -redis~=5.3.0 +redis~=6.0.0 ujson~=5.10.0 WaifuPicsPython==0.2.0 \ No newline at end of file -- 2.39.5 From 534c652bb5f1e224eba42d1355945b2aeb557388 Mon Sep 17 00:00:00 2001 From: Renovate Date: Tue, 13 May 2025 16:05:25 +0300 Subject: [PATCH 3/8] Update dependency redis to ~=6.1.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 306475d..adca629 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,6 @@ async_pymongo==0.1.11 libbot[speed,pycord,cache]==4.1.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 -redis~=6.0.0 +redis~=6.1.0 ujson~=5.10.0 WaifuPicsPython==0.2.0 \ No newline at end of file -- 2.39.5 From ab514cab11c62fcd42e4c1f8ee7b9dcdf5337452 Mon Sep 17 00:00:00 2001 From: Renovate Date: Sun, 18 May 2025 19:29:00 +0300 Subject: [PATCH 4/8] Update dependency libbot to v4.2.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index adca629..f723ccc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ requests>=2.32.2 aiofiles~=24.1.0 apscheduler>=3.10.0 async_pymongo==0.1.11 -libbot[speed,pycord,cache]==4.1.0 +libbot[speed,pycord,cache]==4.2.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 redis~=6.1.0 -- 2.39.5 From ad3eda601a5b4f09814f8f11893bfb65440050ae Mon Sep 17 00:00:00 2001 From: Renovate Date: Wed, 28 May 2025 08:53:49 +0300 Subject: [PATCH 5/8] Update dependency redis to ~=6.2.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f723ccc..b9ecf95 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,6 @@ async_pymongo==0.1.11 libbot[speed,pycord,cache]==4.2.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 -redis~=6.1.0 +redis~=6.2.0 ujson~=5.10.0 WaifuPicsPython==0.2.0 \ No newline at end of file -- 2.39.5 From 2853d0d66eaa97744d726e8244fd4560ef03bd9d Mon Sep 17 00:00:00 2001 From: Renovate Date: Tue, 8 Jul 2025 02:41:34 +0300 Subject: [PATCH 6/8] Update dependency libbot to v4.3.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b9ecf95..2942a52 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ requests>=2.32.2 aiofiles~=24.1.0 apscheduler>=3.10.0 async_pymongo==0.1.11 -libbot[speed,pycord,cache]==4.2.0 +libbot[speed,pycord,cache]==4.3.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 redis~=6.2.0 -- 2.39.5 From efc17fba23339d04b9d2fb020d42f905caae2c9f Mon Sep 17 00:00:00 2001 From: Renovate Date: Wed, 9 Jul 2025 16:00:14 +0300 Subject: [PATCH 7/8] Update dependency libbot to v4.4.0 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2942a52..ad7aeed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,7 +5,7 @@ requests>=2.32.2 aiofiles~=24.1.0 apscheduler>=3.10.0 async_pymongo==0.1.11 -libbot[speed,pycord,cache]==4.3.0 +libbot[speed,pycord,cache]==4.4.0 mongodb-migrations==1.3.1 pymemcache~=4.0.0 redis~=6.2.0 -- 2.39.5 From 79c1f5b1478a54dd377c3f2de82ea48ada0311ad Mon Sep 17 00:00:00 2001 From: profitroll Date: Wed, 9 Jul 2025 16:49:01 +0200 Subject: [PATCH 8/8] Added support for cache prefixes and TTL --- classes/holo_bot.py | 12 ++++++++++-- config_example.json | 6 ++++-- migrations/202507091444.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 migrations/202507091444.py diff --git a/classes/holo_bot.py b/classes/holo_bot.py index aad37a6..fbd4f3d 100644 --- a/classes/holo_bot.py +++ b/classes/holo_bot.py @@ -1,5 +1,6 @@ import logging from logging import Logger +from typing import Literal from libbot.cache.classes import CacheMemcached, CacheRedis from libbot.cache.manager import create_cache_client @@ -16,5 +17,12 @@ class HoloBot(PycordBot): self._set_cache_engine() def _set_cache_engine(self) -> None: - if "cache" in self.config and self.config["cache"]["type"] is not None: - self.cache = create_cache_client(self.config, self.config["cache"]["type"]) + cache_type: Literal["redis", "memcached"] | None = self.config["cache"]["type"] + + if "cache" in self.config and cache_type is not None: + self.cache = create_cache_client( + self.config, + cache_type, + prefix=self.config["cache"][cache_type]["prefix"], + default_ttl_seconds=3600, + ) diff --git a/config_example.json b/config_example.json index 146e50f..8545fb4 100644 --- a/config_example.json +++ b/config_example.json @@ -25,10 +25,12 @@ "cache": { "type": null, "memcached": { - "uri": "127.0.0.1:11211" + "uri": "127.0.0.1:11211", + "prefix": null }, "redis": { - "uri": "redis://127.0.0.1:6379/0" + "uri": "redis://127.0.0.1:6379/0", + "prefix": null } }, "logging": { diff --git a/migrations/202507091444.py b/migrations/202507091444.py new file mode 100644 index 0000000..4a36e17 --- /dev/null +++ b/migrations/202507091444.py @@ -0,0 +1,31 @@ +import logging +from logging import Logger + +from libbot.utils import config_set, config_delete +from mongodb_migrations.base import BaseMigration + +logger: Logger = logging.getLogger(__name__) + + +class Migration(BaseMigration): + def upgrade(self): + try: + config_set("prefix", None, "cache", "memcached") + config_set("prefix", None, "cache", "redis") + except Exception as exc: + logger.error( + "Could not upgrade the config during migration '%s' due to: %s", + __name__, + exc, + ) + + def downgrade(self): + try: + config_delete("prefix", "cache", "redis") + config_delete("prefix", "cache", "memcached") + except Exception as exc: + logger.error( + "Could not downgrade the config during migration '%s' due to: %s", + __name__, + exc, + ) -- 2.39.5