Updating mod_clone by adding action on groups. reloading the module is now using Settings.set_cache and get_cache

This commit is contained in:
adator
2025-08-10 02:31:50 +02:00
parent 1686c4a0b5
commit 21a2619f49
13 changed files with 587 additions and 233 deletions

View File

@@ -1,7 +1,14 @@
'''This class should never be reloaded.
'''
from threading import Timer, Thread, RLock
from socket import socket
from typing import Any
class Settings:
"""This Class will never be reloaded.
Means that the variables are available during
the whole life of the app
"""
RUNNING_TIMERS: list[Timer] = []
RUNNING_THREADS: list[Thread] = []
@@ -13,3 +20,29 @@ class Settings:
PROTOCTL_USER_MODES: list[str] = []
PROTOCTL_PREFIX: list[str] = []
__CACHE: dict[str, Any] = {}
"""Use set_cache or get_cache instead"""
def set_cache(self, key: str, value_to_cache: Any):
"""When you want to store a variable
Ex.
```python
set_cache('MY_KEY', {'key1': 'value1', 'key2', 'value2'})
```
Args:
key (str): The key you want to add.
value_to_cache (Any): The Value you want to store.
"""
self.__CACHE[key] = value_to_cache
def get_cache(self, key) -> Any:
"""It returns the value associated to the key and finally it removes the entry"""
if self.__CACHE.get(key):
return self.__CACHE.pop(key)
return None
def get_cache_size(self) -> int:
return len(self.__CACHE)