[docs]defcache_lookup(key:str,cache:Dict[str,Tuple[str,T]]|List[Tuple[str,T]]|Set[Tuple[str,T]],cap_sensitive=True)->Tuple[str,T]|None:"""Finds and returns object using key from any goldy bot cache object."""ifcap_sensitiveisFalse:key=key.lower()ifisinstance(cache,(list,set)):forobjincache:ifisinstance(obj,tuple):ifkey==(lambdax:x.lower()ifcap_sensitiveisFalseelsex)(obj[0]):returnobjelifisinstance(cache,dict):forobjincache:ifkey==(lambdax:x.lower()ifcap_sensitiveisFalseelsex)(obj):returncache[obj]returnNone
# TODO: Add support for more different cache types.