Package org.jredis.ri.alphazero

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


  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

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

    JRedis jredis = new JRedisClient(spec);

    System.out.println ("** using JRedis **");
   
    useZRangeSubset (jredis);
   
    jredis.quit();
  }
View Full Code Here

      }
    }

    @Override
    public JRedis create() throws Exception {
      return new JRedisClient(connectionSpec);
    }
View Full Code Here

  public RedisConnection getConnection() {
    JredisConnection connection;
    if (pool != null) {
      connection = new JredisConnection(pool.getResource(), pool);
    } else {
      connection = new JredisConnection(new JRedisClient(connectionSpec), null);
    }
    return postProcessConnection(connection);
  }
View Full Code Here

TOP

Related Classes of org.jredis.ri.alphazero.JRedisClient

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.