Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - pscp use Detailed Windows and Linux each file transfer tool (Linux)

- How to create a secure and easy to remember password (Linux)

- Java memory area Explanation (Programming)

- Oracle 11g maintenance partitions (Seven) - Modifying Real Attributes of Partitions (Database)

- MySQL database to open a remote connection method (Database)

- Use window.name + iframe cross-domain access to data Detailed (Programming)

- Dalvik heap memory management and recycling (Linux)

- Element content of Java HashSet change issues (Programming)

- shell script: MySQL monitoring service is normal (Database)

- Use PuTTY key authentication mechanism for remote login Linux (Linux)

- Linux system components Detailed log (Linux)

- Ubuntu How to install screen recording tool Simple Screen Recorder 0.3.1 (Linux)

- grep command Detailed and relevant examples (Linux)

- MySQL 5.6.12 binary log path switching binlog (Database)

- Ubuntu 14.04 jdk Installation and Configuration (Linux)

- Oracle 12C modify spfile path (Database)

- 10 important Linux ps command combat (Linux)

- Java annotations entry automatically generates SQL statements (Programming)

- Modern Objective-C syntax and new features (Programming)

- Search Linux commands and files - which, whereis, locate, find (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:      
 
- Debian (Wheezy) Install Java environment / replace OpenJDK as the SUN JDK (Linux)
- Oracle JDK installation under Ubuntu Linux (Linux)
- ActionContext and ServletActionContext Summary (Programming)
- C ++ Supplements - locates the new expression (Programming)
- Logging information through the web GUI (LogAnalyzer) (Server)
- MySQL development common query summary (Database)
- MySQL DATE_FORMAT () function (Database)
- Linux systems use IP masquerading anti-hacker (Linux)
- About phpwind 5.01-5.3 0day analysis of the article (Linux)
- mydumper installation error process (Database)
- User rights management system under Linux (Linux)
- Lenovo Ultrabooks Ubuntu system can not open the wireless hardware switch solutions (Linux)
- After installing minimize RHEL / CentOS 7 we need to do (Linux)
- Tab set to four spaces in Vim (Linux)
- Java factory pattern (Factory mode) (Programming)
- C ++ runtime environment built on CentOS 6.6 and Oracle database connection (Database)
- To use Java arrays implement the order form (Programming)
- C ++ virtual functions Classic Insights (Programming)
- Ubuntu: To install chat client Chatty 0.6.1 (Linux)
- To modify the existing user ID and comments GPG key (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.