| | |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.test.context.ContextConfiguration; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import redis.clients.jedis.Jedis; |
| | | import redis.clients.jedis.JedisPool; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | |
| | | @Resource |
| | | private LiJinProviderAccountService liJinProviderAccountService; |
| | | |
| | | @Resource |
| | | private JedisPool jedisPool; |
| | | |
| | | @Test |
| | | public void test() { |
| | | String key = "createtblijin-tejia-6872490"; |
| | | System.out.println(redisTemplate.opsForValue().setIfAbsent(key, "1", 120, TimeUnit.SECONDS)); |
| | | |
| | | Jedis jedis = jedisPool.getResource(); |
| | | try { |
| | | System.out.println(jedis.setnx(key, "1")); |
| | | jedis.expire(key, 120); |
| | | } finally { |
| | | jedis.close(); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |