import { Variables , GraphQLResponse } from 'relay-runtime' ; import RelayQueryResponseCache from 'relay-runtime/lib/RelayQueryResponseCache.js' ; import { CacheInterface } from '../../Config' ; type InMemoryCachePropsType = { ttl ? : number ; size ? : number ; } ; class InMemoryCache implements CacheInterface { store : RelayQueryResponseCache ; constructor ( props ? ) { this . store = new RelayQueryResponseCache ( { size : props && props . size ? props . size : 250 , ttl : props && props . ttl ? props . ttl : 60 * 1000 * 5 , } ) ; } get = ( queryID , variables ) : GraphQLResponse => { return this . store . get ( queryID , variables ) ; } ; set = ( queryID , variables , payload ) : void => { this . store . set ( queryID , variables , payload ) ; } ; clear = ( ) : void => { this . store . clear ( ) ; } ; size = ( ) : number => { return this . store . _responses . size ; } ; } export default InMemoryCache ;