forked from Dniel97/artemis
db: add memcache toggle
This commit is contained in:
parent
1f65cfd2eb
commit
b5ccd67940
@ -150,6 +150,12 @@ class DatabaseConfig:
|
|||||||
default=10000,
|
default=10000,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def enable_memcached(self) -> bool:
|
||||||
|
return CoreConfig.get_config_field(
|
||||||
|
self.__config, "core", "database", "enable_memcached", default=True
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def memcached_host(self) -> str:
|
def memcached_host(self) -> str:
|
||||||
return CoreConfig.get_config_field(
|
return CoreConfig.get_config_field(
|
||||||
|
@ -17,7 +17,7 @@ except ModuleNotFoundError:
|
|||||||
|
|
||||||
def cached(lifetime: int = 10, extra_key: Any = None) -> Callable:
|
def cached(lifetime: int = 10, extra_key: Any = None) -> Callable:
|
||||||
def _cached(func: Callable) -> Callable:
|
def _cached(func: Callable) -> Callable:
|
||||||
if has_mc:
|
if has_mc and (cfg and cfg.database.enable_memcached):
|
||||||
hostname = "127.0.0.1"
|
hostname = "127.0.0.1"
|
||||||
if cfg:
|
if cfg:
|
||||||
hostname = cfg.database.memcached_host
|
hostname = cfg.database.memcached_host
|
||||||
|
@ -24,6 +24,7 @@ database:
|
|||||||
sha2_password: False
|
sha2_password: False
|
||||||
loglevel: "warn"
|
loglevel: "warn"
|
||||||
user_table_autoincrement_start: 10000
|
user_table_autoincrement_start: 10000
|
||||||
|
enable_memcached: True
|
||||||
memcached_host: "localhost"
|
memcached_host: "localhost"
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
|
Loading…
Reference in New Issue
Block a user