Examples of JRedisClient


Examples of org.jredis.ri.alphazero.JRedisClient

  }

  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;
   
    try {
      cleandb(jredis);
    } catch (Throwable e) {
      e.printStackTrace();
      return;
    }
   
    for(;;){
      Long counter = null;
      long start = System.nanoTime();
      for(int i=0;i<iters; i++){
        counter = jredis.incr(key);
      }
      long delta_ns = System.nanoTime() - start;
      long delta_ms = TimeUnit.MILLISECONDS.convert(delta_ns, TimeUnit.NANOSECONDS);
      float opsrate = iters/delta_ms;
      System.out.format("counter: %d  msec:%d ops/msecs:%f  [delta:%d]\n", counter, delta_ms, opsrate, delta_ns);
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

      jredis_async = new JRedisPipeline(spec);
      jredis = null;
      break;
    case Synchronous:
      jredis_async = null;
      jredis = new JRedisClient(spec);
      break;
    default:
      throw new IllegalArgumentException("only sync and async modes are supported");
    }
  }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

public class JRedisClientJProfileSubject extends JRedisJProfileSubject{

  public static void main(String[] args) throws RedisException {
    JRedis jredis;
        jredis = new JRedisClient("localhost", 6379, "jredis", 0);
    new JRedisJProfileSubject (jredis).run();
  }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

    new HelloAgain().run(password);
  }

  private void run(String password) {
    try {
      JRedis  jredis = new JRedisClient("localhost", 6379, "jredis", 0);
      jredis.ping();
     
      if(!jredis.exists(key)) {
        jredis.set(key, "Hello Again!");
        System.out.format("Hello!  You should run me again!\n");
      }
      else {
        String msg = toStr ( jredis.get(key) );
        System.out.format("%s\n", msg);
      }
      jredis.quit();
    }
    catch (RedisException e){
      if (e.getCommand()==Command.PING){
        System.out.format("I'll need that password!  Try again with password as command line arg for this program.\n");
      }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

            .setCredentials(password.getBytes())
            .setDatabase(13);
         
          // finally - use it to create the JRedisClient instance
          //
          JRedisClient jredis = new JRedisClient(connectionSpec);
            jredis.ping();
            Log.log("Sweet success -- we're connected using custom TCP settings");
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient custom ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

      // 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();
            Log.log("Sweet success -- we're connected using default specs and various server info settings.");
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient default ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

  public static void usingSyncClient () {
    ConnectionSpec spec = DefaultConnectionSpec.newSpec()
    .setCredentials("jredis".getBytes())
    .setDatabase(10);

    JRedis jredis = new JRedisClient(spec);

    System.out.println ("\nusing the SyncClient: \n\n");
   
    useMSet (jredis);
    useMSetNX (jredis);
    jredis.quit();
  }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

    new JRedisClientBenchmark().runBenchmarks (host, port, workerCnt, reqCnt, size, db);
  }
 
  @Override
  protected final JRedis newConnection(String host, int port, int db, String password) throws ClientRuntimeException {
    return new JRedisClient(host, port, password, db);
  }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

  }

  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!");
        System.out.format("Hello!  You should run me again!\n");
      }
      else {
        String msg = toStr ( jredis.get(bkey) );
        System.out.format("%s\n", msg);
      }
      jredis.quit();
    }
    catch (RedisException e){
      if (e.getCommand()==Command.PING){
        System.out.format("I'll need that password!  Try again with password as command line arg for this program.\n");
      }
View Full Code Here

Examples of org.jredis.ri.alphazero.JRedisClient

            .setCredentials(password.getBytes())
            .setDatabase(13);
         
          // finally - use it to create the JRedisClient instance
          //
          JRedisClient jredis = new JRedisClient(connectionSpec);
            jredis.ping();
            Log.log("Sweet success -- we're connected using custom TCP settings");
          }
          catch (RedisException e) {
            Log.error("Failed to connect to Redis using JRedisClient custom ConnectionSpec -- password perhaps? => " + e.getLocalizedMessage());
          }
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.