MCPcopy
hub / github.com/sansan0/TrendRadar / get

Method get

mcp_server/services/cache_service.py:69–89  ·  view source on GitHub ↗

获取缓存数据 Args: key: 缓存键 ttl: 存活时间(秒),默认15分钟 Returns: 缓存的值,如果不存在或已过期则返回None

(self, key: str, ttl: int = 900)

Source from the content-addressed store, hash-verified

67 self._lock = Lock()
68
69 def get(self, key: str, ttl: int = 900) -> Optional[Any]:
70 """
71 获取缓存数据
72
73 Args:
74 key: 缓存键
75 ttl: 存活时间(秒),默认15分钟
76
77 Returns:
78 缓存的值,如果不存在或已过期则返回None
79 """
80 with self._lock:
81 if key in self._cache:
82 # 检查是否过期
83 if time.time() - self._timestamps[key] < ttl:
84 return self._cache[key]
85 else:
86 # 已过期,删除缓存
87 del self._cache[key]
88 del self._timestamps[key]
89 return None
90
91 def set(self, key: str, value: Any) -> None:
92 """

Callers 15

get_platforms_resourceFunction · 0.80
get_rss_feeds_resourceFunction · 0.80
get_keywords_resourceFunction · 0.80
_get_weight_configFunction · 0.80
compare_platformsMethod · 0.80
analyze_sentimentMethod · 0.80
find_similar_newsMethod · 0.80
search_by_entityMethod · 0.80

Calls

no outgoing calls

Tested by 1

run_test_notificationFunction · 0.64