import hashlib class PartitionedCache: def __init__(self, backend): self.backend = backend # MinIO or local FS # ----------------------------- # BUILD CACHE KEY # ----------------------------- def key(self, action, target): base = f"{target.key()}:{action['hash']}" return hashlib.sha256(base.encode()).hexdigest() # ----------------------------- # EXISTS # ----------------------------- def exists(self, action, target): k = self.key(action, target) return self.backend.exists(k) # ----------------------------- # STORE # ----------------------------- def store(self, action, target, data): k = self.key(action, target) self.backend.put(k, data) # ----------------------------- # FETCH # ----------------------------- def fetch(self, action, target): k = self.key(action, target) return self.backend.get(k)