Example usage for org.apache.http.impl.client.cache.memcached SHA256KeyHashingScheme SHA256KeyHashingScheme

List of usage examples for org.apache.http.impl.client.cache.memcached SHA256KeyHashingScheme SHA256KeyHashingScheme

Introduction

In this page you can find the example usage for org.apache.http.impl.client.cache.memcached SHA256KeyHashingScheme SHA256KeyHashingScheme.

Prototype

SHA256KeyHashingScheme

Source Link

Usage

From source file:org.esigate.cache.MemcachedCacheStorage.java

@Override
public void init(Properties properties) {
    Collection<String> serverStringList = Parameters.MEMCACHED_SERVERS_PROPERTY.getValue(properties);
    if (serverStringList.isEmpty()) {
        throw new ConfigurationException("No memcached server defined. Property '"
                + Parameters.MEMCACHED_SERVERS_PROPERTY + "' must be defined.");
    }//from www.j ava2 s.  c  om
    List<InetSocketAddress> servers = new ArrayList<InetSocketAddress>();
    for (Iterator<String> iterator = serverStringList.iterator(); iterator.hasNext();) {
        String server = iterator.next();
        String[] serverHostPort = server.split(":");
        if (serverHostPort.length != 2) {
            throw new ConfigurationException(
                    "Invalid memcached server: '" + server + "'. Each server must be in format 'host:port'.");
        }
        String host = serverHostPort[0];
        try {
            int port = Integer.parseInt(serverHostPort[1]);
            servers.add(new InetSocketAddress(host, port));
        } catch (NumberFormatException e) {
            throw new ConfigurationException("Invalid memcached server: '" + server
                    + "'. Each server must be in format 'host:port'. Port must be an integer.", e);
        }
    }
    MemcachedClient memcachedClient;
    try {
        memcachedClient = new MemcachedClient(servers);
    } catch (IOException e) {
        throw new ConfigurationException(e);
    }
    CacheConfig cacheConfig = CacheConfigHelper.createCacheConfig(properties);
    setImpl(new MemcachedHttpCacheStorage(memcachedClient, cacheConfig, new MemcachedCacheEntryFactoryImpl(),
            new SHA256KeyHashingScheme()));
}

From source file:org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage.java

/**
 * Create a storage backend using the pre-configured given
 * <i>memcached</i> client./*from  w ww. j  a va2s.c  o  m*/
 * @param cache client to use for communicating with <i>memcached</i>
 */
public MemcachedHttpCacheStorage(final MemcachedClientIF cache) {
    this(cache, CacheConfig.DEFAULT, new MemcachedCacheEntryFactoryImpl(), new SHA256KeyHashingScheme());
}

From source file:org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage.java

/**
 * Create a storage backend using the given <i>memcached</i> client and
 * applying the given cache configuration and cache entry serialization
 * mechanism. <b>Deprecation note:</b> In the process of fixing a bug
 * based on the need to hash logical storage keys onto memcached cache
 * keys, the serialization process was revamped. This constructor still
 * works, but the serializer argument will be ignored and default
 * implementations of the new framework will be used. You can still
 * provide custom serialization by using the
 * {@link #MemcachedHttpCacheStorage(MemcachedClientIF, CacheConfig,
 * MemcachedCacheEntryFactory, KeyHashingScheme)} constructor.
 * @param client how to talk to <i>memcached</i>
 * @param config apply HTTP cache-related options
 * @param serializer <b>ignored</b>
 *
 * @deprecated (4.2) do not use/*from   w  ww  .java 2 s .c o  m*/
 */
@Deprecated
public MemcachedHttpCacheStorage(final MemcachedClientIF client, final CacheConfig config,
        final HttpCacheEntrySerializer serializer) {
    this(client, config, new MemcachedCacheEntryFactoryImpl(), new SHA256KeyHashingScheme());
}