From 69f883f0a5343061f3cacf9c13dc43878ebb81fe Mon Sep 17 00:00:00 2001 From: zhouzhongping Date: Mon, 6 Nov 2023 14:20:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9A=E7=BB=86=E8=8A=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 一言字数 - web 模式缓存 --- src/generator.py | 3 +++ src/tools.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generator.py b/src/generator.py index 3f36c51..60e85ba 100644 --- a/src/generator.py +++ b/src/generator.py @@ -1,9 +1,12 @@ +from functools import lru_cache + from loguru import logger import models import scraper +@lru_cache(maxsize=None) class Generator: def __init__(self, rss): diff --git a/src/tools.py b/src/tools.py index 2fbfd9a..9271267 100644 --- a/src/tools.py +++ b/src/tools.py @@ -109,7 +109,7 @@ def get_yiyan(): :return:一言 """ try: - response = requests.get("https://v1.hitokoto.cn/?c=d&min_length=18&max_length=24&encode=text", + response = requests.get("https://v1.hitokoto.cn/?c=d&min_length=16&max_length=20&encode=text", timeout=30) # Set timeout to 5 seconds if response.status_code == 200: return response.text