com.kangyonggan.app.redis.impl.RedisServiceImpl Maven / Gradle / Ivy
package com.kangyonggan.app.redis.impl;
import com.kangyonggan.app.redis.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @author kangyonggan
* @since 5/5/18
*/
@Service
public class RedisServiceImpl implements RedisService {
@Autowired
private RedisTemplate redisTemplate;
@Override
public void set(String key, Object value) {
redisTemplate.opsForValue().set(key, value);
}
@Override
public void set(String key, Object value, long timeout) {
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
}
@Override
public void set(String key, Object value, long timeout, TimeUnit unit) {
redisTemplate.opsForValue().set(key, value, timeout, unit);
}
@Override
public Object get(String key) {
return redisTemplate.opsForValue().get(key);
}
@Override
public List