Package net.spy.memcached

Examples of net.spy.memcached.MemcachedClient


        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


     * 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(final InetSocketAddress address) throws IOException {
        this(new MemcachedClient(address));
    }
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

    private MemcachedClientIF client;
    private HttpCacheEntrySerializer serializer;
    private final int maxUpdateRetries;

    public MemcachedHttpCacheStorage(InetSocketAddress address) throws IOException {
        this(new MemcachedClient(address));
    }
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

    public ResponseStore createStore() {
        try {
            if (getServers().size() == 0) {
                return ResponseStore.NULL_STORE;
            } else {
                MemcachedClient client = new MemcachedClient(new BinaryConnectionFactory(), getServers());
                return new MemcachedResponseStore(client, _keyPrefix, _readOnly);
            }
        } catch (IOException ex) {
            throw Throwables.propagate(ex);
        }
View Full Code Here

    if (properties.get("servers") == null) {
      System.err.print("Please config the memcached.properties");
      System.exit(1);
    }
    String servers = (String) properties.get("servers");
    MemcachedClient memcachedClient = new MemcachedClient(AddrUtil
        .getAddresses(servers));
    System.out.println("Spymemcached startup");
    warmUp(memcachedClient);

    for (int i = 0; i < THREADS.length; i++) {
      for (int j = 0; j < BYTES.length; j++) {
        int repeats = getReapts(i);
        test(memcachedClient, BYTES[j], THREADS[i], repeats, true);
      }
    }
    memcachedClient.shutdown();

  }
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

      ialist.add(ia);
    } while (i.hasNext());
   
    boolean isbinary = args[1].isEmpty() ? false : new Boolean(args[1].itemAt(0).getStringValue());
   
    MemcachedClient client;
    try {
      client = isbinary ? new MemcachedClient(new BinaryConnectionFactory(), ialist) : new MemcachedClient(ialist);
    } catch (IOException e) {
      throw new XPathException("Can't connect to memcahed server(s)");
    }
   
    // store the client and return the handle of the one.
View Full Code Here

    }

  public Sequence eval( Sequence[] args, Sequence contextSequence ) throws XPathException
  {
    long clientHandle = ((IntegerValue) args[0].itemAt(0)).getLong();
    MemcachedClient client = MemcachedModule.retrieveClient(clientHandle);

    String key = args[1].itemAt(0).getStringValue();
   
    Item data = args[2].itemAt(0);
   
    Object o;
    if (data.getType() == Type.BASE64_BINARY){
      o = ((BinaryValue)data).toJavaObject(byte[].class);
    } else {
      o = data.getStringValue();
    }
   
    int exp = ((IntegerValue) args[3].itemAt(0)).getInt();

    if (isCalledAs("set")){
      client.set(key, exp, o);
    } else if (isCalledAs("add")){
      client.add(key, exp, o);
    } else if (isCalledAs("replace")){
      client.replace(key, exp, o);
    }
       
        return Sequence.EMPTY_SEQUENCE;
   
  }
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.