file module author Surmon <https://github.com/surmon-china>
  import { CacheKey , CacheTTL , SetMetadata } from '@nestjs/common' ; import * as META from '~/constants/meta.constant' ; interface ICacheOption { ttl ? : number ; key ? : string ; disable ? : boolean ; } function description example HttpCache example HttpCache export function HttpCache ( option ) { const { disable , key , ttl = 60 } = option ; return ( _ , __ , descriptor ) => { if ( disable ) { SetMetadata ( META . HTTP_CACHE_DISABLE , true ) ( descriptor . value ) ; return descriptor ; } if ( key ) { CacheKey ( key ) ( descriptor . value ) ; } if ( typeof ttl === 'number' && ! isNaN ( ttl ) ) { CacheTTL ( ttl ) ( descriptor . value ) ; } return descriptor ; } ; } HttpCache . disable = ( _ , __ , descriptor ) => { SetMetadata ( META . HTTP_CACHE_DISABLE , true ) ( descriptor . value ) ; } ;