Examples of ConnectionSpec


Examples of org.jredis.connector.ConnectionSpec

public class UsingJRedisPipelineService {

  final JRedis jredis;
  private UsingJRedisPipelineService() {
    // same as usual.
    ConnectionSpec spec = DefaultConnectionSpec.newSpec();
    spec.setDatabase(11).setCredentials("jredis".getBytes());
   
    // only need to use the specific class.
    jredis = new JRedisPipelineService(spec);
  }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

   */
  @Override
  protected JRedisFuture newProviderInstance () {
    JRedisFuture provider = null;
    try {
      ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(this.host, this.port, this.db2, this.password.getBytes());
      provider = new JRedisChunkedPipeline(connectionSpec);
        }
        catch (ClientRuntimeException e) {
          Log.error(e.getLocalizedMessage());
        }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

    new JRedisServiceBenchmark(poolCnt, host, port, db, password).runBenchmarks (host, port, workerCnt, reqCnt, size, db);
  }
 
  final JRedis jredisService;
    public JRedisServiceBenchmark (int poolCnt, String host, int port, int db, String password) {
    ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec("localhost", 6379, db, "jredis".getBytes());
    jredisService = new JRedisService(connectionSpec, poolCnt);
    super.quitOnRunEnd(false);
    }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

   
    new JRedisPipelineServiceBenchmark(host, port, db, password).runBenchmarks (host, port, workerCnt, reqCnt, size, db);
  }
  final JRedis jredisService;
    public JRedisPipelineServiceBenchmark (String host, int port, int db, String password) {
    ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec("localhost", 6379, db, "jredis".getBytes());
    jredisService = new JRedisPipelineService(connectionSpec);
    super.quitOnRunEnd(false);
    }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

    new HelloAgain().run(password);
  }

  private void run(String password) {
    try {
      ConnectionSpec spec = DefaultConnectionSpec.newSpec().setCredentials(password);
      JRedis  jredis = new JRedisClient(spec);
      jredis.ping();
     
      if(!jredis.exists(bkey)) {
        jredis.set(bkey, "Hello Again!");
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

public class UsingJRedisPipeline extends UsingJRedisFuture {

  public static void main (String[] args) {
    final int database = 13;
    ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
   
      exampleUseofSyncInPipeline(connectionSpec);
    }
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

          String password = "jredis";
          InetAddress address = InetAddress.getLocalHost();
         
          // 1 - get the default connection spec
          //
          ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
         
          // 2 - customize it
          // here we're demonstrating the full set of parameters -- obviously you can just set what you need
          // but DO NOTE that the SO_PREF_XXX properties of TCP sockets must be defined as a set.  See
          // ConnectionSpec for javadoc details.
          //
          // Here we are spec'ing a connection that is NOT kept alive, and obviously is really keen on making sure
          // we connect as fast as possible.  This is a good connectionspec for disposable JRedisClients that are used
          // to issue a few commands and then discarded.  We're minimizing the connection overhead cost.
         
          connectionSpec
            // to be or not to be -- you decide
            //
            .setSocketFlag(Connection.Socket.Flag.SO_KEEP_ALIVE, Boolean.FALSE)        // DO NOT keep socket allive

            // connect retries on connection breaks
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

      // 1st example: using defaults
      // if your server expects a AUTH password, this will fail so see next block
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
        JRedisClient jredis = new JRedisClient(connectionSpec);
        try {
            jredis.ping();
            Log.log("Sweet success -- we're connected using all default values.");
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
      }
     
      // 2nd example: using defaults but setting the password and the database. 
      // also demonstrated using the method chaining on the ConnectionSpec property setters.
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        String password = "jredis";
        int database = 11;
        ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec();
        connectionSpec
          .setCredentials(password.getBytes())
          .setDatabase(database);
       
        JRedisClient jredis = new JRedisClient(connectionSpec);
        try {
            jredis.ping();
            Log.log("Sweet success -- we're connected using %s as password to %d database.", password, database);
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
      }
     
      // final example: using defaults but setting the full set of basic settings 
      {
        // Note that if your localhost:6379 redis server expects a password
        // this will fail
        try {
          String password = "jredis";
          int     port = 6379;
          int     database = 11;
          InetAddress address = InetAddress.getLocalHost();
         
          // 1 - get the default connection spec for the basic settings
          //
          ConnectionSpec connectionSpec = DefaultConnectionSpec.newSpec(address, port, database, password.getBytes());
         
          // finally - use it to create the JRedisClient instance
          //
          JRedisClient jredis = new JRedisClient(connectionSpec);
            jredis.ping();
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

*/

public class PipelineInAction {
  @SuppressWarnings("boxing")
  public static void main (String[] args) {
      final ConnectionSpec spec = DefaultConnectionSpec.newSpec();
      spec.setCredentials("jredis".getBytes());
      spec.setDatabase(13);
      spec.setSocketProperty(SO_RCVBUF, 1024 * 24);
      spec.setSocketProperty(SO_SNDBUF, 1024 * 24);
     
      usingSynchSemantics(spec);
      final boolean forever = true;
     
      runJRedisPipelineSET (spec, 100000, 3, forever);
View Full Code Here

Examples of org.jredis.connector.ConnectionSpec

public class UsingJRedisPipelineService {

  final JRedis jredis;
  private UsingJRedisPipelineService() {
    // same as usual.
    ConnectionSpec spec = DefaultConnectionSpec.newSpec();
    spec.setDatabase(11).setCredentials("jredis".getBytes());
   
    // only need to use the specific class.
    jredis = new JRedisPipelineService(spec);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.