Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - UNIX and class UNIX system security check notes (Linux)

- CentOS 7 Add yum source (Linux)

- Linux file system structure Introduction (Linux)

- Ubuntu buffalo wzr-hp-300nh brush DD-WRT router system (Linux)

- Ubuntu 14.10 How to install office suite Calligra Suite 2.8.7 (Linux)

- CentOS 5.5 install ntop (Linux)

- When Linux Detailed time zone and common function of time (Linux)

- Linux use iptables ban Ping (Linux)

- Mac OS X Server installation and application (Linux)

- Five strokes to find out the IP address you want to know (Linux)

- Linux landing problem (Linux)

- How to create a bootable USB disk to use MultiSystem on Ubuntu (Linux)

- VMware virtual machine to install CentOS 7 (Linux)

- Ubuntu 14.04 Boot Repair (Linux)

- Can not remember how to solve the problem under Ubuntu brightness setting (Linux)

- Deployment Kubernetes manage Docker example cluster on Ubuntu (Server)

- Java reflection technology explain (Programming)

- Nodejs mysql pool Example (Programming)

- Ubuntu System Log Configuration / var / log / messages (Linux)

- Installation under Linux to deploy Java (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:      
 
- To compiler and install MariaDB-10.0.20 under CentOS 6.6 (Database)
- Docker container plaintext password problem-solving way (Server)
- Talk about the Linux ABI compatibility Application (Linux)
- CentOS 7 open ports (Linux)
- Tomcat installation under Linux (Server)
- Android Launcher3 Application List Modify a transparent background (Linux)
- Under Ubuntu on how to use iptables firewall (Linux)
- sqlplus connect to Oracle (Database)
- C language Bubble Sort - integer sort (Programming)
- MySQL stored procedures and triggers (Database)
- Oracle 11g em start newspaper site's security certificate has a solution to the problem (Database)
- CentOS7 install NTFS-3G driver (Linux)
- Linux OOM killer mechanism (Linux)
- Based on Google Cloud Storage Mirroring open Maven Central Repository (Server)
- Oracle 11g forget approach SYS and SYSTEM password (Database)
- How to find out a Unix system library files are 32-bit or 64-bit (Linux)
- Install Linux Mint 17: 20 things to do (Linux)
- Linux install Eclipse for C / C ++ Development (Linux)
- MySQL flip-flop (Database)
- Linux / Unix: chroot command examples to explain (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.