package com.muyu.common.cache;

import com.muyu.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.concurrent.TimeUnit;

/**
 * 抽象缓存层
 */
public abstract class CacheAbsBacis<K, V> implements CacheBasic<K, V> {

    /**
     * 注解
     */
    @Autowired
    private RedisService redisService;

    //存
    @Override
    public void put(K key, V value) {
        redisService.setCacheObject(encode(key), value);
    }

    @Override
    public V get(K key) {
        return redisService.getCacheObject(encode(key));
    }

    @Override
    public void remove(K key) {
        redisService.deleteObject(encode(key));
    }

}
