Using MySQL and memcached with Java-opracowanie

Nasza ocena:

3
Wyświetleń: 469
Komentarze: 0
Notatek.pl

Pobierz ten dokument za darmo

Podgląd dokumentu
Using MySQL and memcached with Java-opracowanie - strona 1

Fragment notatki:

Using MySQL and memcached with Java
The com.danga.MemCached class within Java provides a native interface to memcached instances.
You can obtain the client from https://github.com/gwhalin/Memcached-Java-Client/downloads. The
Java class uses hashes that are compatible with libmemcached, so you can mix and match Java and
libmemcached applications accessing the same memcached instances. The serialization between
Java and other interfaces are not compatible. If this is a problem, use JSON or a similar nonbinary
serialization format.
On most systems, you can download the package and use the jar directly.
To use the com.danga.MemCached interface, you create a MemCachedClient instance and then
configure the list of servers by configuring the SockIOPool. Through the pool specification you set up
the server list, weighting, and the connection parameters to optimized the connections between your
client and the memcached instances that you configure.
Generally, you can configure the memcached interface once within a single class, then use this
interface throughout the rest of your application.
For example, to create a basic interface, first configure the MemCachedClient and base
SockIOPool settings:
public class MyClass {
protected static MemCachedClient mcc = new MemCachedClient();
static {
String[] servers =
{
"localhost:11211",
};
Integer[] weights = { 1 };
SockIOPool pool = SockIOPool.getInstance();
pool.setServers( servers );
pool.setWeights( weights );
In the above sample, the list of servers is configured by creating an array of the memcached instances
to use. You can then configure individual weights for each server.
... zobacz całą notatkę



Komentarze użytkowników (0)

Zaloguj się, aby dodać komentarz