MCPcopy Create free account
hub / github.com/Tong89/smartNode / trim

Method trim

backend/persistence/event_log.py:47–55  ·  view source on GitHub ↗

仅保留最近 max_events 条事件(内存与文件同步),控制存储增长。

(self, max_events)

Source from the content-addressed store, hash-verified

45 return items
46
47 def trim(self, max_events):
48 """仅保留最近 max_events 条事件(内存与文件同步),控制存储增长。"""
49 with self._lock:
50 self._buffer = self._buffer[-max_events:]
51 if self.path:
52 with open(self.path, "w", encoding="utf-8") as f:
53 for rec in self._buffer:
54 f.write(json.dumps(rec, ensure_ascii=False) + "\n")
55 return len(self._buffer)
56
57 @staticmethod
58 def read_file(path):

Callers 5

test_event_log_trimFunction · 0.95
saveApiBaseFunction · 0.80
saveNamedScenarioFunction · 0.80
runCompareFunction · 0.80
setBaseUrlMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_event_log_trimFunction · 0.76