SknCodeRequest.java 1.19 KB
package com.yoho.search.models.recall;

import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.base.utils.ProductIndexEsField;
import com.yoho.search.cache.CacheTimeConstants;
import com.yoho.search.cache.model.ICacheRequest;

import java.util.Arrays;
import java.util.List;

public class SknCodeRequest implements ICacheRequest {

    public static final List<String> includeFields = Arrays.asList(ProductIndexEsField.productSkn,ProductIndexEsField.productSknCode);

    private Integer productSkn;
    private String codeVersion;

    public SknCodeRequest(Integer productSkn,String codeVersion){
        this.productSkn = productSkn;
        this.codeVersion = codeVersion;
    }

    @Override
    public RedisKeyBuilder redisKeyBuilder() {
        return RedisKeyBuilder.newInstance().appendFixed("YOHOSEARCH:").appendFixed("SKN_CODE:").appendVar(codeVersion).appendFixed(":").appendVar(cacheTimeInMinute()).appendFixed(":").appendVar(productSkn);
    }

    @Override
    public int cacheTimeInMinute() {
        return CacheTimeConstants.SKN_CODE;
    }

    public Integer getProductSkn() {
        return productSkn;
    }

}