|
@@ -3,6 +3,9 @@ package cn.seecoder.fdroidrepository.Service.ServiceImpl;
|
|
|
|
|
|
|
|
import cn.seecoder.fdroidrepository.utils.RedisUtil;
|
|
import cn.seecoder.fdroidrepository.utils.RedisUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.data.redis.connection.RedisConnection;
|
|
|
|
|
+import org.springframework.data.redis.connection.RedisStringCommands;
|
|
|
|
|
+import org.springframework.data.redis.core.RedisCallback;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -51,7 +54,24 @@ public class DateService {
|
|
|
throw new IllegalStateException("params can not be null!");
|
|
throw new IllegalStateException("params can not be null!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ List<byte[]> keyList = new ArrayList<>();
|
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
|
+ calendar.setTime(start);
|
|
|
|
|
+ while (!calendar.getTime().after(end)){
|
|
|
|
|
+ String key = RedisUtil.getDAUKey(df.format(calendar.getTime()));
|
|
|
|
|
+ keyList.add(key.getBytes());
|
|
|
|
|
+ calendar.add(Calendar.DATE,1);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ return (long) redisTemplate.execute(new RedisCallback() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Object doInRedis(RedisConnection connection) {
|
|
|
|
|
+ String redisKey = RedisUtil.getDAUKey(df.format(start), df.format(end));
|
|
|
|
|
+ connection.stringCommands().bitOp(RedisStringCommands.BitOperation.OR,
|
|
|
|
|
+ redisKey.getBytes(), keyList.toArray(new byte[0][0]));
|
|
|
|
|
+ return connection.stringCommands().bitCount(redisKey.getBytes());
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|