org.springframework.data.redis.core.RedisTemplate.getRequiredConnectionFactory()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(100)

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

RedisTemplate.getRequiredConnectionFactory介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public <T extends Closeable> T executeWithStickyConnection(RedisCallback<T> callback) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(callback, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  RedisConnection connection = preProcessConnection(RedisConnectionUtils.doGetConnection(factory, true, false, false),
      false);
  return callback.doInRedis(connection);
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public <T> T execute(SessionCallback<T> session) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return session.execute(this);
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

/**
 * Execute a transaction, using the default {@link RedisSerializer}s to deserialize any results that are byte[]s or
 * Collections or Maps of byte[]s or Tuples. Other result types (Long, Boolean, etc) are left as-is in the converted
 * results. If conversion of tx results has been disabled in the {@link RedisConnectionFactory}, the results of exec
 * will be returned without deserialization. This check is mostly for backwards compatibility with 1.0.
 *
 * @return The (possibly deserialized) results of transaction exec
 */
@Override
public List<Object> exec() {
  List<Object> results = execRaw();
  if (getRequiredConnectionFactory().getConvertPipelineAndTxResults()) {
    return deserializeMixedResults(results, valueSerializer, hashKeySerializer, hashValueSerializer);
  } else {
    return results;
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public List<Object> executePipelined(SessionCallback<?> session, @Nullable RedisSerializer<?> resultSerializer) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return execute((RedisCallback<List<Object>>) connection -> {
      connection.openPipeline();
      boolean pipelinedClosed = false;
      try {
        Object result = executeSession(session);
        if (result != null) {
          throw new InvalidDataAccessApiUsageException(
              "Callback cannot return a non-null value as it gets overwritten by the pipeline");
        }
        List<Object> closePipeline = connection.closePipeline();
        pipelinedClosed = true;
        return deserializeMixedResults(closePipeline, resultSerializer, hashKeySerializer, hashValueSerializer);
      } finally {
        if (!pipelinedClosed) {
          connection.closePipeline();
        }
      }
    });
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: spring-projects/spring-data-redis

Assert.notNull(action, "Callback object must not be null");
RedisConnectionFactory factory = getRequiredConnectionFactory();
RedisConnection conn = null;
try {

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public <T extends Closeable> T executeWithStickyConnection(RedisCallback<T> callback) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(callback, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  RedisConnection connection = preProcessConnection(RedisConnectionUtils.doGetConnection(factory, true, false, false),
      false);
  return callback.doInRedis(connection);
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public <T> T execute(SessionCallback<T> session) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return session.execute(this);
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public <T extends Closeable> T executeWithStickyConnection(RedisCallback<T> callback) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(callback, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  RedisConnection connection = preProcessConnection(RedisConnectionUtils.doGetConnection(factory, true, false, false),
      false);
  return callback.doInRedis(connection);
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public <T> T execute(SessionCallback<T> session) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return session.execute(this);
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: org.springframework.data/spring-data-redis

/**
 * Execute a transaction, using the default {@link RedisSerializer}s to deserialize any results that are byte[]s or
 * Collections or Maps of byte[]s or Tuples. Other result types (Long, Boolean, etc) are left as-is in the converted
 * results. If conversion of tx results has been disabled in the {@link RedisConnectionFactory}, the results of exec
 * will be returned without deserialization. This check is mostly for backwards compatibility with 1.0.
 *
 * @return The (possibly deserialized) results of transaction exec
 */
@Override
public List<Object> exec() {
  List<Object> results = execRaw();
  if (getRequiredConnectionFactory().getConvertPipelineAndTxResults()) {
    return deserializeMixedResults(results, valueSerializer, hashKeySerializer, hashValueSerializer);
  } else {
    return results;
  }
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Execute a transaction, using the default {@link RedisSerializer}s to deserialize any results that are byte[]s or
 * Collections or Maps of byte[]s or Tuples. Other result types (Long, Boolean, etc) are left as-is in the converted
 * results. If conversion of tx results has been disabled in the {@link RedisConnectionFactory}, the results of exec
 * will be returned without deserialization. This check is mostly for backwards compatibility with 1.0.
 *
 * @return The (possibly deserialized) results of transaction exec
 */
@Override
public List<Object> exec() {
  List<Object> results = execRaw();
  if (getRequiredConnectionFactory().getConvertPipelineAndTxResults()) {
    return deserializeMixedResults(results, valueSerializer, hashKeySerializer, hashValueSerializer);
  } else {
    return results;
  }
}

代码示例来源:origin: org.springframework.data/spring-data-redis

@Override
public List<Object> executePipelined(SessionCallback<?> session, @Nullable RedisSerializer<?> resultSerializer) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return execute((RedisCallback<List<Object>>) connection -> {
      connection.openPipeline();
      boolean pipelinedClosed = false;
      try {
        Object result = executeSession(session);
        if (result != null) {
          throw new InvalidDataAccessApiUsageException(
              "Callback cannot return a non-null value as it gets overwritten by the pipeline");
        }
        List<Object> closePipeline = connection.closePipeline();
        pipelinedClosed = true;
        return deserializeMixedResults(closePipeline, resultSerializer, hashKeySerializer, hashValueSerializer);
      } finally {
        if (!pipelinedClosed) {
          connection.closePipeline();
        }
      }
    });
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public List<Object> executePipelined(SessionCallback<?> session, @Nullable RedisSerializer<?> resultSerializer) {
  Assert.isTrue(initialized, "template not initialized; call afterPropertiesSet() before using it");
  Assert.notNull(session, "Callback object must not be null");
  RedisConnectionFactory factory = getRequiredConnectionFactory();
  // bind connection
  RedisConnectionUtils.bindConnection(factory, enableTransactionSupport);
  try {
    return execute((RedisCallback<List<Object>>) connection -> {
      connection.openPipeline();
      boolean pipelinedClosed = false;
      try {
        Object result = executeSession(session);
        if (result != null) {
          throw new InvalidDataAccessApiUsageException(
              "Callback cannot return a non-null value as it gets overwritten by the pipeline");
        }
        List<Object> closePipeline = connection.closePipeline();
        pipelinedClosed = true;
        return deserializeMixedResults(closePipeline, resultSerializer, hashKeySerializer, hashValueSerializer);
      } finally {
        if (!pipelinedClosed) {
          connection.closePipeline();
        }
      }
    });
  } finally {
    RedisConnectionUtils.unbindConnection(factory);
  }
}

代码示例来源:origin: org.springframework.data/spring-data-redis

Assert.notNull(action, "Callback object must not be null");
RedisConnectionFactory factory = getRequiredConnectionFactory();
RedisConnection conn = null;
try {

代码示例来源:origin: apache/servicemix-bundles

Assert.notNull(action, "Callback object must not be null");
RedisConnectionFactory factory = getRequiredConnectionFactory();
RedisConnection conn = null;
try {

相关文章

微信公众号

最新文章

更多