基于Redis的Set实现关注和粉丝列表分析
1、定义相关的关注逻辑、我的关注列表、我的粉丝列表
package com.example.service;
import com.example.entity.User;
import com.example.utils.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@Service
public class FollowerService {
@Autowired
private RedisTemplate redisTemplate;
public static final String FOLLOWEE_SET_KEY = "followee:user:";