
package com.tmerclub.cloud.seckill.config;

import com.tmerclub.cloud.common.cache.adapter.CacheTtlAdapter;
import com.tmerclub.cloud.common.cache.bo.CacheNameWithTtlBO;
import com.tmerclub.cloud.common.cache.constant.SeckillCacheNames;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author tmerclub
 * @date 2020/12/18
 */
@Component
public class SeckillCacheTtlAdapter implements CacheTtlAdapter {

    @Override
    public List<CacheNameWithTtlBO> listCacheNameWithTtl() {
        List<CacheNameWithTtlBO> cacheNameWithTtls = new ArrayList<>(4);
        // 秒杀库存信息缓存10秒
        cacheNameWithTtls.add(new CacheNameWithTtlBO(SeckillCacheNames.SECKILL_SKU_BY_SECKILL_ID, 10));
        cacheNameWithTtls.add(new CacheNameWithTtlBO(SeckillCacheNames.SECKILL_SKU_BY_ID, 10));
        cacheNameWithTtls.add(new CacheNameWithTtlBO(SeckillCacheNames.SECKILL_BY_SECKILL_ID, 10));
        cacheNameWithTtls.add(new CacheNameWithTtlBO(SeckillCacheNames.SECKILL_BY_SPU_ID, 10));
        return cacheNameWithTtls;
    }
}
