Package net.spy.memcached

Examples of net.spy.memcached.MemcachedClient


    private MemcachedClient client;

    MemcachedCache(String hostname, int port) {
        try {
            this.client = new MemcachedClient(new InetSocketAddress(hostname, port));
        } catch (IOException e) {
            throw new RuntimeException("Unable to create a Memcached client", e);
        }
    }
View Full Code Here


     * machine as your application, for example.
     * @param address where the <i>memcached</i> daemon is running
     * @throws IOException in case of an error
     */
    public MemcachedHttpCacheStorage(InetSocketAddress address) throws IOException {
        this(new MemcachedClient(address));
    }
View Full Code Here

   *
   * @param addresses
   * @throws IOException
   */
  public Memcached(String addresses) throws IOException {   
    client = new MemcachedClient(new PwaBinaryConnectionFactory(), AddrUtil.getAddresses(addresses));   
                //AddrUtil.getAddresses("server1:11211 server2:11211"));           
      System.out.println("Connected to servers at "+addresses);
  }
View Full Code Here

      String[] hostPort = hostname.split(":");
      addresses.add(new InetSocketAddress(hostPort[0], Integer.parseInt(hostPort[1])));
    }
   
    try {
      this.client = new MemcachedClient(addresses);
    } catch (final IOException e) {
      throw new IllegalStateException(e);
    }
  }
View Full Code Here

*/
@Test
public class TextMemcachedActionTests extends AbstractMemcachedActionsTests {

    @Override protected MemcachedClient createMemcachedClient() throws IOException {
        return new MemcachedClient(AddrUtil.getAddresses("localhost:11211"));
    }
View Full Code Here

*/
@Test
public class BinaryMemcachedActionTests extends AbstractMemcachedActionsTests {

    @Override protected MemcachedClient createMemcachedClient() throws IOException {
        return new MemcachedClient(new BinaryConnectionFactory(), AddrUtil.getAddresses("localhost:11211"));
    }
View Full Code Here

    if(client == null){
      cacheValid = false;
      if(WebVariable.useMemcached){
        try {
          int serverCount = WebVariable.memcachedHosts.split(" ").length;
          client = new MemcachedClient(
    //          "xxxx:11211 yyyy:11211"
                  AddrUtil.getAddresses(hosts));
          Thread.sleep(2000);
          Collection<SocketAddress> unavailableServers = client.getUnavailableServers();
          if(unavailableServers.size()==serverCount){
View Full Code Here

        return new KestrelEndpoint(uri, this, config, queue);
    }

    public MemcachedClient getMemcachedClient(KestrelConfiguration config, String queue) {
        String key = config.getAddressesAsString() + "/" + queue;
        MemcachedClient memcachedClient = memcachedClientCache.get(key);
        if (memcachedClient != null) {
            return memcachedClient;
        }
        synchronized (memcachedClientCache) {
            if ((memcachedClient = memcachedClientCache.get(key)) == null) {
                LOG.info("Creating MemcachedClient for " + key);
                try {
                    memcachedClient = new MemcachedClient(memcachedConnectionFactory, config.getInetSocketAddresses());
                } catch (Exception e) {
                    throw new RuntimeCamelException("Failed to connect to " + key, e);
                }
                memcachedClientCache.put(key, memcachedClient);
            }
View Full Code Here

      sb.append(s + " ");
    }
    this.poolName = poolName;
    try {
      for(int i = 0;i < getPoolSize() ;i++) {
        memPool.add(new MemcachedClient(new KetamaConnectionFactory(), AddrUtil.getAddresses(sb.toString())));
      }
      //client.setTranscoder(new SerializingTranscoder());
      //Logger.getLogger(SerializingTranscoder.class.getName()).setLevel(Level.WARNING);
      //client.setTranscoder(new WhalinTranscoder());
    } catch (Exception e) {
View Full Code Here

     * machine as your application, for example.
     * @param address where the <i>memcached</i> daemon is running
     * @throws IOException in case of an error
     */
    public MemcachedHttpCacheStorage(InetSocketAddress address) throws IOException {
        this(new MemcachedClient(address));
    }
View Full Code Here

TOP

Related Classes of net.spy.memcached.MemcachedClient

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.