Package org.jredis.connector

Examples of org.jredis.connector.ConnectionSpec


  }

  @Override
  public void run() {
    int database = 11;
    ConnectionSpec connSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
    JRedisFuture jredis = new JRedisChunkedPipeline(connSpec);
   
    byte[] key = "cpct".getBytes();
    int iters = 100000;
   
View Full Code Here


    }
  }

  private void run() throws RedisException {
    int database = 11;
    ConnectionSpec connSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
    JRedis jredis = new JRedisClient(connSpec);
   
    byte[] key = "bench-jredis-pipeline-key".getBytes();
    int iters = 100 * 1000;
   
 
View Full Code Here

    new SimpleBenchJRedisPipeline().run();
  }

  private void run() {
    int database = 11;
    ConnectionSpec connSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
    JRedisFuture jredis = new JRedisPipeline(connSpec);
   
    byte[] key = "pipe".getBytes();
    int iters = 100 * 1000;
   
 
View Full Code Here

    InetAddress   address = null;
    Connection     synchConnection = null;
    try {
     
      address = InetAddress.getByName(host);
      ConnectionSpec spec = DefaultConnectionSpec.newSpec(address, port, database, credentials);
      synchConnection = createSynchConnection(spec, isShared, redisVersion);
      Assert.notNull(synchConnection, "connection delegate", ClientRuntimeException.class);
    }
    catch (UnknownHostException e) {
      String msg = "Couldn't obtain InetAddress for "+host;
View Full Code Here

    new SimpleBenchJRedisAsync().run();
  }

  private void run() {
    int database = 11;
    ConnectionSpec connSpec = DefaultConnectionSpec.newSpec("localhost", 6379, database, "jredis".getBytes());
    JRedisFuture jredis = new JRedisAsyncClient(connSpec);
   
    byte[] key = "bench-jredis-pipeline-key".getBytes();
    int iters = 100 * 1000;
   
 
View Full Code Here

public class UsingJRedisPipeline extends UsingJRedisFuture {

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

          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(SocketFlag.SO_KEEP_ALIVE, false)        // DO NOT keep socket allive

            // connect retries on connection breaks
View Full Code Here

      // 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

*
*/

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

  private ClusterSuiteTestData () {
//    ClusterNodeSpec nodeSpec = null;
    connSpecs = new ConnectionSpec[NODE_CNT];
    for(int i=0;i<NODE_CNT; i++) {
      InetAddress address = getInetAddressFor(CLUSTER_NODES_ADDRESS_BASE);
      ConnectionSpec connSpec = getConnectionSpecFor(address, CLUSTER_NODES_PORT_BASE+i, db);
      connSpecs[i] = connSpec;
//      nodeSpec = new DefaultClusterNodeSpec (connSpec);
//      clusterNodeSpecs.add(nodeSpec);
    }
View Full Code Here

TOP

Related Classes of org.jredis.connector.ConnectionSpec

Copyright © 2018 www.massapicom. 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.