io.vertx.redis.RedisClient.transaction()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中io.vertx.redis.RedisClient.transaction方法的一些代码示例,展示了RedisClient.transaction的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RedisClient.transaction方法的具体详情如下:
包路径:io.vertx.redis.RedisClient
类名称:RedisClient
方法名:transaction

RedisClient.transaction介绍

[英]Return a RedisTransaction instance
[中]返回一个事务实例

代码示例

代码示例来源:origin: io.vertx/vertx-rx-java

/**
 * Return a RedisTransaction instance
 * @return transaction instance
 */
public io.vertx.rxjava.redis.RedisTransaction transaction() { 
 io.vertx.rxjava.redis.RedisTransaction ret = io.vertx.rxjava.redis.RedisTransaction.newInstance(delegate.transaction());
 return ret;
}

代码示例来源:origin: vert-x3/vertx-rx

/**
 * Return a RedisTransaction instance
 * @return transaction instance
 */
public io.vertx.rxjava.redis.RedisTransaction transaction() { 
 io.vertx.rxjava.redis.RedisTransaction ret = io.vertx.rxjava.redis.RedisTransaction.newInstance(delegate.transaction());
 return ret;
}

代码示例来源:origin: sczyh30/vertx-kue

client.transaction()
 .multi(_failure())
 .zrange(key, 0, 0, _failure())

代码示例来源:origin: sczyh30/vertx-kue

JobState oldState = this.state;
logger.debug("Job::state(from: " + oldState + ", to:" + newState.name() + ")");
client.transaction().multi(r0 -> {
 if (r0.succeeded()) {
  if (oldState != null && !oldState.equals(newState)) {
   client.transaction().zrem(RedisHelper.getStateKey(oldState), this.zid, _failure())
    .zrem(RedisHelper.getKey("jobs:" + this.type + ":" + oldState.name()), this.zid, _failure());
  client.transaction().hset(RedisHelper.getKey("job:" + this.id), "state", newState.name(), _failure())
   .zadd(RedisHelper.getKey("jobs:" + newState.name()), this.priority.getValue(), this.zid, _failure())
   .zadd(RedisHelper.getKey("jobs:" + this.type + ":" + newState.name()), this.priority.getValue(), this.zid, _failure());
    client.transaction().zadd(RedisHelper.getKey("jobs:" + newState.name()),
     this.priority.getValue() < 0 ? this.priority.getValue() : -this.priority.getValue(),
     this.zid, _failure());
    break;
   case DELAYED:
    client.transaction().zadd(RedisHelper.getKey("jobs:" + newState.name()),
     this.promote_at, this.zid, _failure());
    break;
   case INACTIVE:
    client.transaction().lpush(RedisHelper.getKey(this.type + ":jobs"), "1", _failure());
    break;
   default:
  client.transaction().exec(r -> {
   if (r.succeeded()) {
    future.complete(this);

代码示例来源:origin: sczyh30/vertx-kue

/**
 * Remove the job.
 */
public Future<Void> remove() {
 Future<Void> future = Future.future();
 client.transaction().multi(_failure())
  .zrem(RedisHelper.getKey("jobs:" + this.stateName()), this.zid, _failure())
  .zrem(RedisHelper.getKey("jobs:" + this.type + ":" + this.stateName()), this.zid, _failure())
  .zrem(RedisHelper.getKey("jobs"), this.zid, _failure())
  .del(RedisHelper.getKey("job:" + this.id + ":log"), _failure())
  .del(RedisHelper.getKey("job:" + this.id), _failure())
  .exec(r -> {
   if (r.succeeded()) {
    this.emit("remove", new JsonObject().put("id", this.id));
    future.complete();
   } else {
    future.fail(r.cause());
   }
  });
 return future;
}

代码示例来源:origin: sczyh30/vertx-kue

/**
 * Update the job.
 */
Future<Job> update() {
 Future<Job> future = Future.future();
 this.updated_at = System.currentTimeMillis();
 client.transaction().multi(_failure())
  .hmset(RedisHelper.getKey("job:" + this.id), this.toJson(), _failure())
  .zadd(RedisHelper.getKey("jobs"), this.priority.getValue(), this.zid, _failure())
  .exec(_completer(future, this));
 // TODO: add search functionality (full-index engine, for Chinese language this is difficult)
 return future.compose(r ->
  this.state(this.state));
}

代码示例来源:origin: sczyh30/vertx-kue

client.transaction().multi(null)
 .del(RedisHelper.getKey("job:" + id + ":log"), null)
 .del(RedisHelper.getKey("job:" + id), null)

相关文章

RedisClient类方法