MCPcopy Create free account
hub / github.com/TQZHR/grok2api / _save_usage_data

Method _save_usage_data

app/services/api_keys.py:171–180  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

169 self._usage_loaded = True
170
171 async def _save_usage_data(self):
172 if not self._usage_loaded:
173 return
174 try:
175 self.usage_path.parent.mkdir(parents=True, exist_ok=True)
176 async with self._usage_lock:
177 content = orjson.dumps(self._usage, option=orjson.OPT_INDENT_2)
178 await asyncio.to_thread(self.usage_path.write_bytes, content)
179 except Exception as e:
180 logger.error(f"[ApiKey] Usage 保存失败: {e}")
181
182 def generate_key(self) -> str:
183 """生成一个新的 sk- 开头的 key"""

Callers 1

consume_daily_usageMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected