Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - Learning C language pointer essays (Programming)

- Django how to generate content in non-HTML formats (Programming)

- Cacti installation deployment under CentOS 6.6 (Server)

- Java semaphores (Programming)

- Linux environment variable configuration (Linux)

- How to query the role of Linux services (Linux)

- Use Redis as time-series database: why and how (Database)

- Linux common network tools: batch scanning of nmap hosting service (Linux)

- Taught you how to build your own VPS server (Server)

- ORA-28000 the account is locked fault simulation (Database)

- CentOS 7 x64 compiler installation Tengine 2.0.3 Comments (Server)

- Linux command to view the system status (Linux)

- Learning UNIX good habits (Linux)

- Vim simple configuration (Linux)

- Transplant spider to MySQL 5.6 (Database)

- Firewall settings oracle remote connection in Linux systems (Linux)

- Linux system started to learn: how to solve the xxx is not in the sudoers file error (Linux)

- Hadoop new and old version of the difference in the size of the InputSplit (Server)

- To install Internet security firewall Raiders (Linux)

- Source compiler install Nginx (Server)

 
         
  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:      
 
- Linux system components Detailed log (Linux)
- Introduction Linux namespace (Linux)
- Linux open handle limit adjustment (Linux)
- Linux environment password security settings (Linux)
- Oracle database with test data insertion speed (Database)
- Linux development environment to build and use the directory structure and file --Linux (Linux)
- To deploy MySQL database with separate read and write OneProxy (Database)
- Tomcat itself through simple movement separation (Server)
- To compile and install OpenCV-2.3.1 FFmpeg-2.1.2 under CentOS (Linux)
- C ++ class implementation date operator overloading (Programming)
- top command causes the system load increases (Linux)
- Generated characters using Java Videos (Programming)
- Linux common network tools: hping Advanced Host Scan (Linux)
- LVM management parameters commonly used commands explained in detail (Linux)
- Talk about Java in the collection (Programming)
- MySQL remote connection settings (Database)
- The Objects in JavaScript (Programming)
- How to use the on-screen keyboard in Linux (Linux)
- Linux package manager - yum (Linux)
- Gitblit adopted Ticket collaborative development model (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.