Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
85f1205410 | |||
4fc37f72f3 | |||
b9aeaf5c86 | |||
6087349622 | |||
3010dc02bc | |||
4afcbc93d5 | |||
72ccaa04a4 |
@@ -1,6 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
from logging import Logger
|
from logging import Logger
|
||||||
from typing import Literal
|
|
||||||
|
|
||||||
from libbot.cache.classes import CacheMemcached, CacheRedis
|
from libbot.cache.classes import CacheMemcached, CacheRedis
|
||||||
from libbot.cache.manager import create_cache_client
|
from libbot.cache.manager import create_cache_client
|
||||||
@@ -17,12 +16,5 @@ class HoloBot(PycordBot):
|
|||||||
self._set_cache_engine()
|
self._set_cache_engine()
|
||||||
|
|
||||||
def _set_cache_engine(self) -> None:
|
def _set_cache_engine(self) -> None:
|
||||||
cache_type: Literal["redis", "memcached"] | None = self.config["cache"]["type"]
|
if "cache" in self.config and self.config["cache"]["type"] is not None:
|
||||||
|
self.cache = create_cache_client(self.config, 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,
|
|
||||||
)
|
|
||||||
|
@@ -25,12 +25,10 @@
|
|||||||
"cache": {
|
"cache": {
|
||||||
"type": null,
|
"type": null,
|
||||||
"memcached": {
|
"memcached": {
|
||||||
"uri": "127.0.0.1:11211",
|
"uri": "127.0.0.1:11211"
|
||||||
"prefix": null
|
|
||||||
},
|
},
|
||||||
"redis": {
|
"redis": {
|
||||||
"uri": "redis://127.0.0.1:6379/0",
|
"uri": "redis://127.0.0.1:6379/0"
|
||||||
"prefix": null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"logging": {
|
"logging": {
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
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,
|
|
||||||
)
|
|
@@ -5,9 +5,9 @@ requests>=2.32.2
|
|||||||
aiofiles~=24.1.0
|
aiofiles~=24.1.0
|
||||||
apscheduler>=3.10.0
|
apscheduler>=3.10.0
|
||||||
async_pymongo==0.1.11
|
async_pymongo==0.1.11
|
||||||
libbot[speed,pycord,cache]==4.4.0
|
libbot[speed,pycord,cache]==4.1.0
|
||||||
mongodb-migrations==1.3.1
|
mongodb-migrations==1.3.1
|
||||||
pymemcache~=4.0.0
|
pymemcache~=4.0.0
|
||||||
redis~=6.4.0
|
redis~=5.2.1
|
||||||
ujson~=5.11.0
|
ujson~=5.10.0
|
||||||
WaifuPicsPython==0.2.0
|
WaifuPicsPython==0.2.0
|
Reference in New Issue
Block a user