V getFromMap(String key, K field);
+
+ /**
+ * 将指定的值添加到有序集合中
+ *
+ * @param key 键
+ * @param value 值
+ */
+ void addToSortedSet(String key, String value);
+
+ /**
+ * 获取 Redis 锁(可重入锁)
+ *
+ * @param key 键
+ * @return Lock
+ */
+ RLock getLock(String key);
+
+ /**
+ * 获取 Redis 锁(公平锁)
+ *
+ * @param key 键
+ * @return Lock
+ */
+ RLock getFairLock(String key);
+
+ /**
+ * 获取 Redis 锁(读写锁)
+ *
+ * @param key 键
+ * @return RReadWriteLock
+ */
+ RReadWriteLock getReadWriteLock(String key);
+
+ /**
+ * 获取 Redis 信号量
+ *
+ * @param key 键
+ * @return RSemaphore
+ */
+ RSemaphore getSemaphore(String key);
+
+ /**
+ * 获取 Redis 过期信号量
+ *
+ * 基于Redis的Redisson的分布式信号量(Semaphore)Java对象RSemaphore采用了与java.util.concurrent.Semaphore相似的接口和用法。
+ * 同时还提供了异步(Async)、反射式(Reactive)和RxJava2标准的接口。
+ *
+ * @param key 键
+ * @return RPermitExpirableSemaphore
+ */
+ RPermitExpirableSemaphore getPermitExpirableSemaphore(String key);
+
+ /**
+ * 闭锁
+ *
+ * @param key 键
+ * @return RCountDownLatch
+ */
+ RCountDownLatch getCountDownLatch(String key);
+
+ /**
+ * 布隆过滤器
+ *
+ * @param key 键
+ * @param 存放对象
+ * @return 返回结果
+ */
+ RBloomFilter getBloomFilter(String key);
+
+ Boolean setNx(String key);
+
+ Boolean setNx(String key, long expired, TimeUnit timeUnit);
+
+ RBitSet getBitSet(String key);
+
+ default int getIndexFromUserId(String userId) {
+ try {
+ MessageDigest md = MessageDigest.getInstance("MD5");
+ byte[] hashBytes = md.digest(userId.getBytes(StandardCharsets.UTF_8));
+ // 将哈希字节数组转换为正整数
+ BigInteger bigInt = new BigInteger(1, hashBytes);
+ // 取模以确保索引在合理范围内
+ return bigInt.mod(BigInteger.valueOf(Integer.MAX_VALUE)).intValue();
+ } catch (NoSuchAlgorithmException e) {
+ throw new RuntimeException("MD5 algorithm not found", e);
+ }
+ }
+
+}
diff --git a/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/RedissonService.java b/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/RedissonService.java
new file mode 100644
index 0000000..a7d1fd4
--- /dev/null
+++ b/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/RedissonService.java
@@ -0,0 +1,182 @@
+package edu.whut.infrastructure.redis;
+import org.redisson.api.*;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.time.Duration;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Redis 服务 - Redisson
+ */
+@Service("redissonService")
+public class RedissonService implements IRedisService {
+
+ @Resource
+ private RedissonClient redissonClient;
+
+ public void setValue(String key, T value) {
+ redissonClient.getBucket(key).set(value);
+ }
+
+ @Override
+ public void setValue(String key, T value, long expired) {
+ RBucket bucket = redissonClient.getBucket(key);
+ bucket.set(value, Duration.ofMillis(expired));
+ }
+
+ public T getValue(String key) {
+ return redissonClient.getBucket(key).get();
+ }
+
+ @Override
+ public RQueue getQueue(String key) {
+ return redissonClient.getQueue(key);
+ }
+
+ @Override
+ public RBlockingQueue getBlockingQueue(String key) {
+ return redissonClient.getBlockingQueue(key);
+ }
+
+ @Override
+ public RDelayedQueue getDelayedQueue(RBlockingQueue rBlockingQueue) {
+ return redissonClient.getDelayedQueue(rBlockingQueue);
+ }
+
+ @Override
+ public void setAtomicLong(String key, long value) {
+ redissonClient.getAtomicLong(key).set(value);
+ }
+
+ @Override
+ public Long getAtomicLong(String key) {
+ return redissonClient.getAtomicLong(key).get();
+ }
+
+ @Override
+ public long incr(String key) {
+ return redissonClient.getAtomicLong(key).incrementAndGet();
+ }
+
+ @Override
+ public long incrBy(String key, long delta) {
+ return redissonClient.getAtomicLong(key).addAndGet(delta);
+ }
+
+ @Override
+ public long decr(String key) {
+ return redissonClient.getAtomicLong(key).decrementAndGet();
+ }
+
+ @Override
+ public long decrBy(String key, long delta) {
+ return redissonClient.getAtomicLong(key).addAndGet(-delta);
+ }
+
+ @Override
+ public void remove(String key) {
+ redissonClient.getBucket(key).delete();
+ }
+
+ @Override
+ public boolean isExists(String key) {
+ return redissonClient.getBucket(key).isExists();
+ }
+
+ public void addToSet(String key, String value) {
+ RSet set = redissonClient.getSet(key);
+ set.add(value);
+ }
+
+ public boolean isSetMember(String key, String value) {
+ RSet set = redissonClient.getSet(key);
+ return set.contains(value);
+ }
+
+ public void addToList(String key, String value) {
+ RList list = redissonClient.getList(key);
+ list.add(value);
+ }
+
+ public String getFromList(String key, int index) {
+ RList list = redissonClient.getList(key);
+ return list.get(index);
+ }
+
+ @Override
+ public RMap getMap(String key) {
+ return redissonClient.getMap(key);
+ }
+
+ public void addToMap(String key, String field, String value) {
+ RMap map = redissonClient.getMap(key);
+ map.put(field, value);
+ }
+
+ public String getFromMap(String key, String field) {
+ RMap map = redissonClient.getMap(key);
+ return map.get(field);
+ }
+
+ @Override
+ public V getFromMap(String key, K field) {
+ return redissonClient.getMap(key).get(field);
+ }
+
+ public void addToSortedSet(String key, String value) {
+ RSortedSet sortedSet = redissonClient.getSortedSet(key);
+ sortedSet.add(value);
+ }
+
+ @Override
+ public RLock getLock(String key) {
+ return redissonClient.getLock(key);
+ }
+
+ @Override
+ public RLock getFairLock(String key) {
+ return redissonClient.getFairLock(key);
+ }
+
+ @Override
+ public RReadWriteLock getReadWriteLock(String key) {
+ return redissonClient.getReadWriteLock(key);
+ }
+
+ @Override
+ public RSemaphore getSemaphore(String key) {
+ return redissonClient.getSemaphore(key);
+ }
+
+ @Override
+ public RPermitExpirableSemaphore getPermitExpirableSemaphore(String key) {
+ return redissonClient.getPermitExpirableSemaphore(key);
+ }
+
+ @Override
+ public RCountDownLatch getCountDownLatch(String key) {
+ return redissonClient.getCountDownLatch(key);
+ }
+
+ @Override
+ public RBloomFilter getBloomFilter(String key) {
+ return redissonClient.getBloomFilter(key);
+ }
+
+ @Override
+ public Boolean setNx(String key) {
+ return redissonClient.getBucket(key).trySet("lock");
+ }
+
+ @Override
+ public Boolean setNx(String key, long expired, TimeUnit timeUnit) {
+ return redissonClient.getBucket(key).trySet("lock", expired, timeUnit);
+ }
+
+ @Override
+ public RBitSet getBitSet(String key) {
+ return redissonClient.getBitSet(key);
+ }
+
+}
diff --git a/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/package-info.java b/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/package-info.java
deleted file mode 100644
index 582d29d..0000000
--- a/group-buying-sys-infrastructure/src/main/java/edu/whut/infrastructure/redis/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * 提供redis链接配置
- */
-package edu.whut.infrastructure.redis;
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index b201ea8..88da436 100644
--- a/pom.xml
+++ b/pom.xml
@@ -116,6 +116,12 @@
1.15