from __future__ import annotations class SourceCache: def __init__(self):self.data={} def put_role(self,ref,version,role,payload):self.data[(ref,version,role)]=payload def check_role(self,ref,version,role): if (ref,version,role) in self.data:return {'status':'HIT','payload':self.data[(ref,version,role)]} if any(r==ref and ro==role and v!=version for r,v,ro in self.data):return {'status':'REFRESH_VERSION_CHANGED'} if any(r==ref and v==version for r,v,ro in self.data):return {'status':'MISS_ROLE'} return {'status':'MISS_SOURCE'}