mirror of
https://github.com/PaiGramTeam/MibooGram.git
synced 2024-11-16 21:00:27 +00:00
f122e21092
* 增加 html to image 缓存 * 对 template_service.render 进行封装,管理缓存逻辑 * cache key 为 html 的 sha256 * cache value 为 reply_photo 后 telegram 返回的 file_id * 存入 redis,并设置合理的 ttl Co-authored-by: 洛水居室 <luoshuijs@outlook.com> Co-authored-by: xtaodada <xtao@xtaolink.cn>
14 lines
528 B
Python
14 lines
528 B
Python
from core.base.aiobrowser import AioBrowser
|
|
from core.service import init_service
|
|
from core.base.redisdb import RedisDB
|
|
from core.template.services import TemplateService
|
|
from core.template.cache import TemplatePreviewCache, HtmlToFileIdCache
|
|
|
|
|
|
@init_service
|
|
def create_template_service(browser: AioBrowser, redis: RedisDB):
|
|
_preview_cache = TemplatePreviewCache(redis)
|
|
_html_to_file_id_cache = HtmlToFileIdCache(redis)
|
|
_service = TemplateService(browser, _html_to_file_id_cache, _preview_cache)
|
|
return _service
|