package com.ruoyi.system.utils;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

@Component
public class RedisUtils {

    Jedis jedis = new Jedis("localhost", 6379);

    /**
     * 读取缓存
     *
     * @param key
     * @return
     */
    public String get( String key) {
        try{
            String value = jedis.get(key);
            return value;
        }finally{
            jedis.close();
        }

    }

    /**
     * 写入缓存
     */
    public boolean set(final String key, String value) {
        try {
            jedis.set(key, value);
            return true;
        } finally {
            jedis.close();
        }
    }

}
