MeUtils 2024.12.12.19.4.48__py3-none-any.whl → 2024.12.12.19.7.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: MeUtils
3
- Version: 2024.12.12.19.4.48
3
+ Version: 2024.12.12.19.7.5
4
4
  Summary: description
5
5
  Home-page: https://github.com/yuanjie-ai/MeUtils
6
6
  Author: yuanjie
@@ -62,42 +62,42 @@ Requires-Dist: sse-starlette ; extra == 'ai'
62
62
  Requires-Dist: openai ; extra == 'ai'
63
63
  Requires-Dist: langchain ; extra == 'ai'
64
64
  Provides-Extra: all
65
- Requires-Dist: jinja2 ; extra == 'all'
66
- Requires-Dist: fastapi[all] ; extra == 'all'
67
- Requires-Dist: redis-py-cluster ; extra == 'all'
68
- Requires-Dist: langchain ; extra == 'all'
69
- Requires-Dist: fastapi ; extra == 'all'
70
- Requires-Dist: cachetools ; extra == 'all'
71
65
  Requires-Dist: pymongo ; extra == 'all'
72
- Requires-Dist: asyncmy ; extra == 'all'
73
- Requires-Dist: pymysql ; extra == 'all'
66
+ Requires-Dist: seaborn ; extra == 'all'
74
67
  Requires-Dist: gunicorn ; extra == 'all'
75
- Requires-Dist: pymilvus ; extra == 'all'
68
+ Requires-Dist: polars ; extra == 'all'
69
+ Requires-Dist: sse-starlette ; extra == 'all'
70
+ Requires-Dist: schedule ; extra == 'all'
71
+ Requires-Dist: fastapi ; extra == 'all'
72
+ Requires-Dist: geopy ; extra == 'all'
73
+ Requires-Dist: simplejson ; extra == 'all'
74
+ Requires-Dist: jieba ; extra == 'all'
75
+ Requires-Dist: pretty-errors ; extra == 'all'
76
+ Requires-Dist: uvicorn ; extra == 'all'
77
+ Requires-Dist: dataframe-image ; extra == 'all'
78
+ Requires-Dist: jinja2 ; extra == 'all'
79
+ Requires-Dist: fastapi[all] ; extra == 'all'
76
80
  Requires-Dist: reportlab ; extra == 'all'
81
+ Requires-Dist: iteration-utilities ; extra == 'all'
82
+ Requires-Dist: redis-py-cluster ; extra == 'all'
83
+ Requires-Dist: faiss-cpu ; extra == 'all'
77
84
  Requires-Dist: pandas-profiling[notebook] ; extra == 'all'
78
85
  Requires-Dist: pandas-summary ; extra == 'all'
86
+ Requires-Dist: filetype ; extra == 'all'
87
+ Requires-Dist: cachetools ; extra == 'all'
88
+ Requires-Dist: missingno ; extra == 'all'
89
+ Requires-Dist: langchain ; extra == 'all'
79
90
  Requires-Dist: pymupd ; extra == 'all'
80
91
  Requires-Dist: pyarrow ; extra == 'all'
81
- Requires-Dist: sse-starlette ; extra == 'all'
82
- Requires-Dist: iteration-utilities ; extra == 'all'
83
- Requires-Dist: pretty-errors ; extra == 'all'
84
- Requires-Dist: schedule ; extra == 'all'
85
- Requires-Dist: seaborn ; extra == 'all'
86
- Requires-Dist: missingno ; extra == 'all'
87
- Requires-Dist: openai ; extra == 'all'
88
- Requires-Dist: uvicorn ; extra == 'all'
89
- Requires-Dist: faiss-cpu ; extra == 'all'
90
92
  Requires-Dist: thriftpy2 ; extra == 'all'
93
+ Requires-Dist: asyncmy ; extra == 'all'
94
+ Requires-Dist: thefuck ; extra == 'all'
95
+ Requires-Dist: openai ; extra == 'all'
96
+ Requires-Dist: pymysql ; extra == 'all'
97
+ Requires-Dist: sqlalchemy ; extra == 'all'
91
98
  Requires-Dist: jmespath ; extra == 'all'
92
- Requires-Dist: simplejson ; extra == 'all'
93
99
  Requires-Dist: streamlit ; extra == 'all'
94
- Requires-Dist: polars ; extra == 'all'
95
- Requires-Dist: sqlalchemy ; extra == 'all'
96
- Requires-Dist: jieba ; extra == 'all'
97
- Requires-Dist: thefuck ; extra == 'all'
98
- Requires-Dist: filetype ; extra == 'all'
99
- Requires-Dist: dataframe-image ; extra == 'all'
100
- Requires-Dist: geopy ; extra == 'all'
100
+ Requires-Dist: pymilvus ; extra == 'all'
101
101
  Provides-Extra: ann
102
102
  Requires-Dist: pymilvus ; extra == 'ann'
103
103
  Requires-Dist: faiss-cpu ; extra == 'ann'
@@ -138,6 +138,7 @@ examples/cache_demo/__init__.py,sha256=zYdsVkzlPyaHOyG9HpW_AMriiEH_Pi8AmLUOS7Jbg
138
138
  examples/cache_demo/acacge.py,sha256=rlwMWUO4tWi9Y-gXnFUsRn__N_AaPP0icDlwDAYcf1Y,577
139
139
  examples/cache_demo/demo.py,sha256=iGuQTfV23eqtGIB8QqfQYa7qRNGPxqkUNAcws-fsh60,2528
140
140
  examples/cache_demo/test.py,sha256=gWY_oMf76RSqXdTHGOCcd-7cObkw8X1hovSVPHeyjkk,427
141
+ examples/cache_demo/x.py,sha256=AC51p_wCrWJYa56t7Cx-G2pUTJi7XCvW6VlnXM8fy7k,489
141
142
  examples/caches/__init__.py,sha256=vUpPT-UpH1mFDO2gv5mI7hACcBJYMiIgmb2r4Pr2yUo,271
142
143
  examples/celery_demo/__init__.py,sha256=d3jEYE9LZjFyMly5Djp5vVMlDcmWL5IE6vQoK-tVgK0,271
143
144
  examples/celery_demo/producer.py,sha256=py3Tjcb140zc5mzOGbxf2QIV6ZsXLPX1gjOnHXGysvk,342
@@ -449,8 +450,8 @@ meutils/async_utils/asyncer_.py,sha256=S1Sp5WZx_uKM7kJyRVYU8QhmbjOh61JmfN2IN_PJN
449
450
  meutils/async_utils/background.py,sha256=dl6UaMIFBZDB1uxSZzGFJdSnpt3Xo0flK7gwsokVy78,1464
450
451
  meutils/async_utils/common.py,sha256=WIQ7CVaZiaUeFA3IInM_4uaehJQiTdr_g3Q_8_yQrgc,4899
451
452
  meutils/async_utils/test.py,sha256=lkZdgSzzgVg8hYVcaBNEJ3KBvFTEfjbXZVvtknQZsRQ,1155
452
- meutils/cache/__init__.py,sha256=7ke7BKRUkp1raYrsgOIojHHdeHYNstw9APIdBNDNRzc,2129
453
- meutils/cache/hcache.py,sha256=AgiYUjKO8cfm6uuxQ2nWeaRmf9jkv2AIMvkbMvh_nkU,1139
453
+ meutils/cache/__init__.py,sha256=2JSElkhHh0vhUCvpBhTEsglw7WdkYj2HsAQutbqiBUM,242
454
+ meutils/cache/redis_cache.py,sha256=AgiYUjKO8cfm6uuxQ2nWeaRmf9jkv2AIMvkbMvh_nkU,1139
454
455
  meutils/clis/__init__.py,sha256=2Fhn43X8kFP6FpAnnAMiPcdnjUwQaukiIr2uGB6mGAY,279
455
456
  meutils/clis/browser.py,sha256=eMQ-7LlFJN_Sqs0DMnCVulfdUv9aGhHm5drCViQm4CY,4511
456
457
  meutils/clis/check_api.py,sha256=WKsLupPlM0PI6SzfVOwoqoYNEmOj_Jb-bsRDYA_SXsE,2367
@@ -479,7 +480,7 @@ meutils/config_utils/lark_utils/demo.py,sha256=3g0Fs7oLaeW75T60gYWMLgyNg1OnfOjfH
479
480
  meutils/config_utils/lark_utils/x.py,sha256=MlMQGhehP9xMEgetxVCX68XFaosfKoW1JA5cZ3JqN2w,1857
480
481
  meutils/crawlers/__init__.py,sha256=TBU4xA-IOsHV-0yIkW7YXxn_QT7TT8NncqxO7IykEfs,271
481
482
  meutils/data/SimHei.ttf,sha256=-XEnekS5yHP_URkT4XBI2w22ylV-KxudhkeIYFbrILA,10062565
482
- meutils/data/VERSION,sha256=dVfZd2A1H6Eivbd-XprrXnpN0aIbQ359KN1yqy-9m5A,19
483
+ meutils/data/VERSION,sha256=ySgDen9uEnZP5as6GwTlN8BgeSo69B0ACD4GA6kpaiM,19
483
484
  meutils/data/_FLAG,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
484
485
  meutils/data/_SUCCESS,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
485
486
  meutils/data/__init__.py,sha256=Hfwkkxs4zHqKhxht0YrhS566a9P5axtmgNvM5wF8ceQ,243
@@ -816,9 +817,9 @@ meutils/tools/seize.py,sha256=nOKAS63w-Lbi48I0m2MPhdsokUTwxco0laPxYVmW4Mw,1064
816
817
  meutils/tools/service_monitor.py,sha256=ibsLtBN2g2DL7ZnLJ8vhiZOiOcqTAyx711djDdBK-3M,1255
817
818
  meutils/tools/sys_monitor.py,sha256=6MoyzrItqDUOSjfHcMJmMofQkEPTW36CT_aKui0rg84,429
818
819
  meutils/tools/token_monitor.py,sha256=Np-YK-R4P4IPAXyZvMxwvXI4sFmNJQAQK1lSegNaYpA,997
819
- MeUtils-2024.12.12.19.4.48.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
820
- MeUtils-2024.12.12.19.4.48.dist-info/METADATA,sha256=Jv1oYUjQjZ-E2BC4oZs_08Aq1pDdkB3333xZvh-lKOU,6170
821
- MeUtils-2024.12.12.19.4.48.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
822
- MeUtils-2024.12.12.19.4.48.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
823
- MeUtils-2024.12.12.19.4.48.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
824
- MeUtils-2024.12.12.19.4.48.dist-info/RECORD,,
820
+ MeUtils-2024.12.12.19.7.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
821
+ MeUtils-2024.12.12.19.7.5.dist-info/METADATA,sha256=aJTc0trtJu222lHLpsSDBKaetlb6mWz3Q8x0jLnDgog,6169
822
+ MeUtils-2024.12.12.19.7.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
823
+ MeUtils-2024.12.12.19.7.5.dist-info/entry_points.txt,sha256=lufZlBHRqqZKdY-ZQJ4CSZb0qhV5hQC37egZna9M7ug,357
824
+ MeUtils-2024.12.12.19.7.5.dist-info/top_level.txt,sha256=cInfxMmkgNOskurdjwP5unau4rA7Uw48nu07tYhS7KY,22
825
+ MeUtils-2024.12.12.19.7.5.dist-info/RECORD,,
@@ -0,0 +1,27 @@
1
+
2
+ #!/usr/bin/env python
3
+ # -*- coding: utf-8 -*-
4
+ # @Project : AI. @by PyCharm
5
+ # @File : x
6
+ # @Time : 2024/12/12 19:05
7
+ # @Author : betterme
8
+ # @WeChat : meutils
9
+ # @Software : PyCharm
10
+ # @Description :
11
+
12
+ from meutils.pipe import *
13
+ from meutils.cache.redis_cache import cache
14
+
15
+
16
+
17
+
18
+ if __name__ == '__main__':
19
+ class Request(BaseModel):
20
+ a: str = "a"
21
+
22
+ class Config:
23
+ frozen = True
24
+
25
+
26
+ arun(func(1))
27
+ # arun(func_ignore(1, 11))
meutils/cache/__init__.py CHANGED
@@ -6,77 +6,4 @@
6
6
  # @Author : betterme
7
7
  # @WeChat : meutils
8
8
  # @Software : PyCharm
9
- # @Description :
10
-
11
- from meutils.pipe import *
12
-
13
- import time
14
- from functools import lru_cache, wraps
15
-
16
-
17
- def ttl_fn(ttl: int = 60):
18
- return time.time() // ttl # 缓存时间
19
-
20
-
21
- def lru_cache_with_ttls(maxsize=128, typed: bool = False, ttl: Optional[int] = None):
22
- cache = lru_cache(maxsize, typed)
23
-
24
- @wrapt.decorator # 主逻辑
25
- def inner(wrapped, instance, args, kwargs):
26
-
27
- @cache
28
- def _wrapped(_ttl):
29
- return wrapped(*args, **kwargs)
30
-
31
- return _wrapped(ttl_fn(ttl))
32
-
33
- return inner
34
-
35
-
36
- def lru_cache_with_ttl(maxsize=128, typed: bool = False, ttl: Optional[int] = None):
37
- def decorator(func):
38
- # 使用lru_cache作为基础缓存机制
39
- lru = lru_cache(maxsize=maxsize)(func)
40
- lru_cache_data = {}
41
-
42
- @wraps(func)
43
- def wrapper(*args, **kwargs):
44
- # 生成缓存键
45
- key = args + tuple(kwargs.items())
46
-
47
- # 检查是否在缓存中以及是否过期
48
- if key in lru_cache_data:
49
- entry, timestamp = lru_cache_data[key]
50
- if time.time() - timestamp < ttl:
51
- return entry
52
- else:
53
- # 如果过期,删除缓存
54
- del lru_cache_data[key]
55
-
56
- # 调用原始函数并缓存结果
57
- result = lru(*args, **kwargs)
58
- lru_cache_data[key] = (result, time.time())
59
- return result
60
-
61
- # 使用lru_cache的缓存信息函数
62
- wrapper.cache_info = lru.cache_info
63
- wrapper.cache_clear = lru.cache_clear
64
- return wrapper
65
-
66
- return decorator
67
-
68
-
69
- # 示例使用
70
-
71
-
72
- if __name__ == '__main__':
73
- @lru_cache_with_ttls(maxsize=128, ttl=3)
74
- def expensive_function(n):
75
- logger.debug("不走缓存")
76
- return n
77
-
78
-
79
- print(expensive_function(11))
80
- print(expensive_function(11))
81
- time.sleep(5)
82
- print(expensive_function(11))
9
+ # @Description :
meutils/data/VERSION CHANGED
@@ -1 +1 @@
1
- 2024.12.12.19.04.48
1
+ 2024.12.12.19.07.05
File without changes