Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - Use nice, cpulimit and cgroups limit cpu usage (Linux)

- To use yum install VLC under CentOS (Linux)

- Mount and unloading disks under Linux (Linux)

- 8 Docker knowledge you may not know (Server)

- Apache2.4.7 make an error [exports.lo] Error 1 Solution (Server)

- How to install new fonts on Ubuntu 14.04 and 14.10 (Linux)

- Ubuntu FAQ solutions (Linux)

- Ubuntu install Geary (Linux)

- ORA-00600 error solve one case (Database)

- Linux check disk parameters trapping lack amendments (Linux)

- When a software RAID data recovery and reconstruction of how failure (Linux)

- XP virtual machine under VirtualBox solve occupy 100% CPU problem (Linux)

- React Getting Started Tutorial (Linux)

- Talk about the Linux ABI compatibility Application (Linux)

- 11 you Linux Terminal Command (Linux)

- Kali Linux resolve GPG error KEYEXPIRED 1425567400 (Linux)

- Hadoop2.4.0 Eclipse plug-in making (Server)

- The Zabbix2.4.5 source compiler installation under Ubuntu 14.04 (Server)

- Ubuntu achieve initialization iptables (Linux)

- Use OpenSSL for RSA encryption and decryption (Linux)

 
         
  Java by Spy Memcached to cache data
     
  Add Date : 2018-11-21      
         
         
         
  After configuring Magent + memcached, input and output of data between the obvious is through a proxy server, magent proxy server is doing is evident in memecached call java driver magent apply.

Pick SpyMemcached to cache data.

1. Define a User

Note: The type must be serialized

package memdemo;

import java.io.Serializable;

public class User implements Serializable {

/ **

    *

    * /

    private static final long serialVersionUID = 1L;

private int id;

private String name;

private int age;

public int getId () {

    return id;

}

public void setId (int id) {

    this.id = id;

}

public String getName () {

    return name;

}

public void setName (String name) {

    this.name = name;

}

public int getAge () {

    return age;

}

public void setAge (int age) {

    this.age = age;

}

@Override

public String toString () {

    return "User [id =" + id + ", name =" + name + ", age =" + age + "]";

}

}

2. Write a test class


package memdemo;

 

import java.io.IOException;

import java.net.InetSocketAddress;

 

import org.junit.Test;

 

import net.spy.memcached.MemcachedClient;

 

public class SpyMemcachedTest {

private static MemcachedClient client;

static {

    InetSocketAddress ia = new InetSocketAddress ( "127.0.0.1", 2222);

    try {

        client = new MemcachedClient (ia);

    } Catch (IOException e) {

        // TODO Auto-generated catch block

        e.printStackTrace ();

    }

}

@Test

public void add () {

    client.add ( "swder", 1, "maybo");

    System.out.println (client.get ( "swder") toString ().);

}

@Test

public void addUser () {

    User user = new User ();

    user.setAge (23);

    user.setId (1);

    user.setName ( "maybo");

    //client.add("user123 ", 0, user);

    System.out.println (client.get ( "user123") toString ().);

}

}
     
         
         
         
  More:      
 
- Android Activity launchMode (Programming)
- Basic data types JavaScript type system and the type of packaging (Programming)
- Linux system security knowledge (Linux)
- MariaDB phpMyAdmin installation and configuration issues to resolve under CentOS7 (Database)
- Windows 7 hard disk installation notes Debian (Linux)
- Puppet Detailed centralized configuration management system (Server)
- Ubuntu 10.10 install Oracle 10g graphic tutorials (Database)
- Gentoo: !!! existing preserved libs problem (Linux)
- Oracle bug Ora-04043 (Database)
- Use OpenSSL for RSA encryption and decryption (Linux)
- Lua4.0 interpreter entrance (Programming)
- Git Getting Started tutorial (Linux)
- Oracle 11g can not export a variety of empty table solution (Database)
- About Java 7 module system (Programming)
- C ++ Object Model Comments (Programming)
- Redis-- persistence articles (Database)
- Linux 10 useful examples of command-line completion (Linux)
- Linux System Tutorial: How to browse the Linux command line, weather forecast (Linux)
- Ubuntu 14.10 PPA installed Android Studio (Linux)
- To create and manage virtual machines on Ubuntu Redhat (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.