redis缓存hset, hget, hPutAll

本文介绍了Redis缓存中HSET、HGET及HPUTALL的使用方法,详细阐述了这三个命令在实际业务场景中的应用。
摘要由CSDN通过智能技术生成

redis缓存hset, hget, hPutAll 在业务场景中使用

package com.miniso.pintea.core.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.miniso.pintea.common.constant.redis.CoreRedisConstant;
import com.miniso.pintea.common.util.JsonUtil;
import com.miniso.pintea.core.constant.StoreDailyStatus;
import com.miniso.pintea.core.constant.StoreStatus;
import com.miniso.pintea.core.dto.*;
import com.miniso.pintea.core.entity.StoreInformation;
import com.miniso.pintea.core.mapper.StoreInformationMapper;
import com.miniso.pintea.core.service.StoreInformationService;
import com.miniso.pintea.core.third.service.AMapWebApiCallService;
import com.miniso.pintea.core.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.text.Collator;
import java.text.MessageFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 门店信息 服务实现类
 * </p>
 *
 * @author chenqixuan
 * @since 2021-02-24
 */
@Slf4j
@Service
public class StoreInformationServiceImpl implements StoreInformationService {
   

    @Autowired
    private RedisUtil redisUtil;

    @Autowired
    private StoreInformationMapper storeInformationMapper;

    @Autowired
    private AMapWebApiCallService aMapWebApiCallService;

    @Value("${store.location.distance}")
    private Integer storeDistance;


    @Override
    public List<StoreLocationInfo> getNearbyStoreList4Sf(NearbyStoreRequestDTO nearbyStoreRequestDto, String city,String district, int pageNum, int pageSize) {
   
        List<StoreLocationInfo> storeLocationInfos = new ArrayList<>();
        Integer limitDistance = 10000;
        if(null != storeDistance){
   
            limitDistance = storeDistance;//查附近多少公里的默认设置为10公里(单位米)
        }
        try {
   
            city = city.endsWith("市") || city.endsWith("州") || city.endsWith("区") ? city.substring(0, city.length() - 1) : city;
            Double longitudeN = nearbyStoreRequestDto.getReceiverLng();
            Double latitudeN = nearbyStoreRequestDto.getReceiverLat();

            List<StoreInformation> storeInfoList = getAllStoreInfoRedis();//从缓存取数据

            if(null != storeInfoList && storeInfoList.size() > 0){
   
                if(StringUtils.isNotBlank(city)){
   //城市
                    String finalCity = city;
                    storeInfoList = storeInfoList.stream().filter(s-> s.getStoreCity() == null ? false : s.getStoreCity().contains(finalCity)).collect(Collectors.toList());
                }
                if(StringUtils.isNotBlank(district)){
   //区域
                    storeInfoList = storeInfoList.stream().filter(s-> s.getStoreDistrict() == null ? false : s.getStoreDistrict().contains(district)).collect(Collectors.toList());
                }

                for (StoreInformation storeInfo : storeInfoList) {
   
                    StoreLocationInfo storeLocationInfo = new Store
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值