package com.gic.haoban.manage.service.util;


import com.gic.redis.data.util.RedisUtil;
import org.redisson.api.RBucket;
import org.redisson.api.RedissonClient;

import java.util.concurrent.TimeUnit;

/**
 * Created by wangzubo on 2025/3/5.
 */
public class IntervalUtils {

    private static final String INTERVAL_KEY = "haoban-manage3-service:interval_potential:%s:%s:%s";

    public static boolean tryAddInterval(String clerkId,String memberId,String unionId) {
        String key = String.format(INTERVAL_KEY, clerkId, memberId, unionId);
        RedissonClient redisClient = RedisUtil.getRedisClient();
        RBucket<Object> bucket = redisClient.getBucket(key);
        boolean trySet = bucket.trySet(1, 10, TimeUnit.SECONDS);
        if (!trySet) {
            return false;
        }
        return true;
    }

}
