Authored by hugufei

添加redis bitset测试接口

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