def find_by_type(self, key_type: str, tenant_id: TenantId) -> Optional[KeyStore]: hit, key_store = CacheService.key_store().get(key_type, tenant_id) if hit: return key_store storage_service = KeyStoreStorageService(ask_meta_storage()) storage_service.begin_transaction() try: key_store: KeyStore = storage_service.find_by_type( key_type, tenant_id) if key_store is None: CacheService.key_store().declare_not_existing( key_type, tenant_id) return None CacheService.key_store().put(key_store) return key_store finally: storage_service.close_transaction()
async def clear_all_tenants_cache( principal_service: PrincipalService = Depends( get_super_admin_principal)) -> None: CacheService.key_store().clear()