Andres Alvarez
Front-End Developer
Cache-Control: public, max-age=31536000
304 Not Modified
@cache@s-ui/decorator
import {UseCase} from '@s-ui/domain'
import {inlineError, cache} from '@s-ui/decorators'
// uses params as keys
export class GetSeoTagsSearchUseCase extends UseCase {
@cache({
server: true,
ttl: '1 minute'
})
async execute({params}) {
const [seoTagsError, seoTagsResponse] = await this._service.execute({
params
})
if (seoTagsError) {
return Promise.reject(seoTagsError)
}
return seoTagsResponse?.toJSON()
}
}import {UseCase} from '@s-ui/domain'
import {inlineError, cache} from '@s-ui/decorators'
export class GetSeoTagsSearchUseCase extends UseCase {
@cache({
server: true,
ttl: '1 minute',
redis: {host: 'localhost', port: 6379}
})
async execute({adSearchParamsAggregate}) {
const [seoTagsError, seoTagsResponse] = await this._service.execute({
adSearchParamsAggregate
})
if (seoTagsError) {
return Promise.reject(seoTagsError)
}
return seoTagsResponse?.toJSON()
}
}const cache = {}
const execute = (id) => {
// hit
// more conditions could be added e.g. ttl
if (cache[id] !== undefined) {
return cache[id]
}
// miss
const value = compute(id)
cache[id] = value
}
execute('1')@cachereact-queryswr