package com.muyu.common.cache;

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

/**
 *  抽象缓存层
 * @Author：yang
 * @Package：com.muyu.common
 * @Project：cloud-server-8
 * @name：CacheAbsBacis
 * @Date：2024/9/30 11:19
 */
public abstract class CacheAbsBasic<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));
    }
}
