import json, os class MemoryStore: def __init__(self, path): self.path = path if not os.path.exists(path): open(path, 'w').close() def add(self, record): with open(self.path, 'a') as f: f.write(json.dumps(record) + "\n")