public Map<Wallets, String> getAnalytics() {
   Map<Wallets, String> walletTransactionCount = new HashMap<Wallets, String>();
   walletTransactionCount.put(
       Wallets.PAYTM, template.opsForValue().get(Wallets.PAYTM.getTransactionCountKey()));
   walletTransactionCount.put(
       Wallets.CITRUS, template.opsForValue().get(Wallets.CITRUS.getTransactionCountKey()));
   walletTransactionCount.put(
       Wallets.PAYUMONEY, template.opsForValue().get(Wallets.PAYUMONEY.getTransactionCountKey()));
   return walletTransactionCount;
 }
 public boolean ifAlreadyExists(Merchant merchant, Wallets wallet) {
   String merchantId =
       template
           .opsForValue()
           .get("merchant." + merchant.getName() + wallet.getRedisMerchantIdKey());
   return merchantId == null ? false : true;
 }
示例#3
0
 @Override
 public void doLoad(String filename) throws ConfigParseException {
   XmlParser<GlobalXMLCO> parser = new XmlParser<GlobalXMLCO>(GlobalXMLCO.class, filename);
   GlobalXMLCO obj = parser.parse();
   for (String id : obj.getMap().keySet()) {
     globalTemplate.opsForValue().set(KEY + id, obj.getMap().get(id));
   }
 }
  public String add(User user) {

    String sid = new SessionToolUtil().generateSessionId();

    ValueOperations<String, User> valueops = redisTemplate.opsForValue();
    valueops.set(sid, user);

    return sid;
  }
  @RequestMapping(value = "/xdanalytics/orders", method = RequestMethod.GET)
  public @ResponseBody List<OrderAnalytics> orderAnalyticsFromXd() {

    redisTemplate.setKeySerializer(new StringRedisSerializer());
    redisTemplate.setValueSerializer(new StringRedisSerializer());

    OrderAnalytics oaAll =
        new OrderAnalytics(
            "richgauges.order_gauge",
            (String) redisTemplate.opsForValue().get("richgauges.order_gauge"));
    OrderAnalytics oaFraud =
        new OrderAnalytics(
            "richgauges.fraud_order_gauge",
            (String) redisTemplate.opsForValue().get("richgauges.fraud_order_gauge"));
    ArrayList<OrderAnalytics> oaList = new ArrayList<OrderAnalytics>();
    oaList.add(oaAll);
    oaList.add(oaFraud);
    return oaList;
  }
 @RequestMapping(
     value = "/get",
     method = RequestMethod.GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<Map<String, String>> Get() {
   String msg = redisTemplate.opsForValue().get("msg");
   Map<String, String> re = new HashMap<>();
   re.put("msg", msg);
   return new ResponseEntity<Map<String, String>>(re, HttpStatus.OK);
 }
  public Merchant getDetails(String merchantName) {
    String baseKey = "merchant." + merchantName;

    Merchant merchant = new Merchant();

    // or use template directly
    merchant.setName(template.opsForValue().get(baseKey + ".name"));
    merchant.setPhoneNumber(template.opsForValue().get(baseKey + ".phone"));
    merchant.setEmail(template.opsForValue().get(baseKey + ".email"));
    merchant
        .getWalletMerchantId()
        .put(
            Wallets.PAYTM,
            template.opsForValue().get(baseKey + Wallets.PAYTM.getRedisMerchantIdKey()));
    merchant
        .getWalletMerchantId()
        .put(
            Wallets.PAYUMONEY,
            template.opsForValue().get(baseKey + Wallets.PAYUMONEY.getRedisMerchantIdKey()));
    merchant
        .getWalletMerchantId()
        .put(
            Wallets.CITRUS,
            template.opsForValue().get(baseKey + Wallets.CITRUS.getRedisMerchantIdKey()));

    return merchant;
  }
  @Override
  public NotificationApikey findByAppId(Integer appid) {

    NotificationApikey cache =
        (NotificationApikey)
            slaveRedisTemplate.opsForValue().get(Constans.CLOUD_PUSH_API_KEY_PREFIX + appid);
    if (cache != null) {
      return cache;
    }

    NotificationApikey key = new NotificationApikey();
    key.setAppid(appid);
    List<NotificationApikey> list = this.findListByParamsObjs(key);
    if (list != null && list.size() > 0) {
      NotificationApikey result = list.get(0);
      masterRedisTemplate.opsForValue().set(Constans.CLOUD_PUSH_API_KEY_PREFIX + appid, result);
      masterRedisTemplate.expire(Constans.CLOUD_PUSH_API_KEY_PREFIX + appid, 4, TimeUnit.HOURS);
      return result;
    }

    return null;
  }
  @RequestMapping(
      value = "/set/{msg}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<Map<String, String>> Set(@PathVariable("msg") String msg) {
    redisTemplate.opsForValue().set("msg", msg); // 与下面写法一样的效果

    //        redisTemplate.execute(new RedisCallback<Boolean>() {
    //            @Override
    //            public Boolean doInRedis(RedisConnection redisConnection) throws
    // DataAccessException {
    //                byte [] key = "msg".getBytes();
    //                byte[] value = msg.getBytes();
    //                redisConnection.set(key, value);
    //                return true;
    //            }
    //        });

    return new ResponseEntity<Map<String, String>>(HttpStatus.OK);
  }
示例#10
0
 public Object get(Object key) {
   return redisSlave.opsForValue().get(key);
 }
示例#11
0
 public boolean put(Object key, Object value, long timeout, TimeUnit unit) {
   redisMaster.opsForValue().set(key, value, timeout, unit);
   return true;
 }
示例#12
0
 public boolean put(Object key, Object value) {
   redisMaster.opsForValue().set(key, value);
   return true;
 }
示例#13
0
 @Override
 public GlobalCO get(String id) {
   return globalTemplate.opsForValue().get(KEY + id);
 }
示例#14
0
 /**
  * /** String数据类型 如果value存储的是Integer类型值则增加
  *
  * @param key
  * @param value
  * @return 递增后的新增
  * @throws InvalidDataAccessApiUsageException value不是Integer类型时报错
  */
 public long increment(String key, long value) throws InvalidDataAccessApiUsageException {
   valueOps = redisTemplate.opsForValue();
   return valueOps.increment(key, value);
 }
 public void setValue(final String key, final String value, final Long expireSeconds) {
   redisTemplate.opsForValue().set(key, value, expireSeconds, TimeUnit.SECONDS);
 }
 public void setValue(final String key, final String value) {
   redisTemplate.opsForValue().set(key, value);
 }
 public Object getValue(final String key) {
   return redisTemplate.opsForValue().get(key);
 }
示例#18
0
 public CaptainLevelCO get(long captainLevelId) {
   String key = PREFIX + captainLevelId;
   CaptainLevelCO captainLevel = captainLevelTemplate.opsForValue().get(key);
   return captainLevel;
 }
示例#19
0
 // @Test
 public void testL() {
   System.out.println(redisWinTemplateLoc.getClass());
   ValueOperations<Serializable, Serializable> op = redisWinTemplateLoc.opsForValue();
   System.out.println(op == null);
 }
示例#20
0
 /**
  * String数据类型 读取键为key的值 支持value非String类型
  *
  * @param key
  * @return value值
  */
 public Serializable get(String key) {
   valueOps = redisTemplate.opsForValue();
   return valueOps.get(key);
 }
 public void registerTransaction(Wallets wallet) {
   template.opsForValue().increment(wallet.getTransactionCountKey(), 1);
 }
示例#22
0
 // String数据类型 存储一对键值 支持value为非String类型
 public void set(String key, Serializable value) {
   valueOps = redisTemplate.opsForValue();
   valueOps.set(key, value);
 }
示例#23
0
 // String数据类型 存储一对键值并设置有效时间 支持value为非String类型
 public void set(String key, Serializable value, long timeout, TimeUnit unit) {
   valueOps = redisTemplate.opsForValue();
   valueOps.set(key, value, timeout, unit);
 }
示例#24
0
 // String数据类型  将value追加到已存在的某key的value值末尾
 public void append(String key, String value) {
   valueOps = redisTemplate.opsForValue();
   valueOps.append(key, value);
 }
 @PostConstruct
 public void init() {
   operations = template.opsForValue();
   hashOperations = template.opsForHash();
 }
  public User get(String id) {

    ValueOperations<String, User> valueops = redisTemplate.opsForValue();
    User user = valueops.get(id);
    return user;
  }
示例#27
0
 public void put(CaptainLevelCO captainLevel) {
   String key = PREFIX + captainLevel.getId();
   captainLevelTemplate.opsForValue().set(key, captainLevel);
 }
 @Override
 public ValueOperations getValOper() {
   return template.opsForValue();
 }