TestRedisController.java
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.yoho.search.restapi.tools;
import com.yoho.core.redis.cluster.operations.serializer.RedisKeyBuilder;
import com.yoho.search.common.cache.impls.SearchRedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Map;
@Controller
public class TestRedisController {
@Autowired
private SearchRedis searchRedis;
@RequestMapping(value = "/testRedis/bitset")
@ResponseBody
public Map<String, Object> testBitset() {
long begin = System.currentTimeMillis();
for (int i = 0; i < 10000; i++) {
BitSet bitSet = new BitSet(100000);
for (int j = 0; j < 10000; j++) {
bitSet.set(j);
}
bitSet.set(100000);
RedisKeyBuilder redisKeyBuilder = new RedisKeyBuilder();
redisKeyBuilder.appendFixed("RedisBitSet:").appendVar(System.currentTimeMillis());
redisKeyBuilder.appendFixed(":").appendVar((int) (Math.random() * 1000));
searchRedis.setBitSet(redisKeyBuilder, bitSet, 100);
}
Map result = new HashMap<>();
result.put("code", 200);
result.put("messgae", "success");
result.put("cost", System.currentTimeMillis() - begin);
return result;
}
}