import { JwtPayload } from '../jsonwebtoken-type' ; import { Cache , IsolationStrategy } from '../cache' ; import { Destination } from './destination-service-types' ; import { getDestinationCacheKey } from './destination-cache' ; const DestinationServiceCache = ( cache ) => ( { retrieveDestinationsFromCache : ( targetUrl , decodedJwt , isolationStrategy ? ) : Destination [ ] | undefined => cache . get ( getDestinationCacheKeyService ( targetUrl , decodedJwt , isolationStrategy ) ) , cacheRetrievedDestinations : ( destinationServiceUri , decodedJwt , destinations , isolationStrategy ? ) : void => { const key = getDestinationCacheKeyService ( destinationServiceUri , decodedJwt , isolationStrategy ) ; cache . set ( key , destinations ) ; } , clear : ( ) => { cache . clear ( ) ; } , getCacheInstance : ( ) => cache } ) ; function getDestinationCacheKeyService ( destinationServiceUri , decodedJwt , isolationStrategy ? ) { const usedIsolationStrategy = isolationStrategy === IsolationStrategy . Tenant || isolationStrategy === IsolationStrategy . Tenant_User ? isolationStrategy : IsolationStrategy . Tenant ; return getDestinationCacheKey ( decodedJwt , destinationServiceUri , usedIsolationStrategy ) ; } internal export const destinationServiceCache = DestinationServiceCache ( new Cache < Destination [ ] > ( { hours : 0 , minutes : 5 , seconds : 0 } ) ) ;