springboot中的redisTemplate封装了redis批处理数据的接口,我们使用redisTemplate可以直接进行批量数据的get和set。
package com.huateng.applacation.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @program: applacation
* @description:
* @author: daiwenlong
* @create: 2019-01-24 13:26
**/
@Component
public class RedisService {
@Autowired
@Qualifier("stringRedisTemplate")
private StringRedisTemplate redisTemplate;
public void insertKey(List<String> keys, String value){
//批量get数据
List