Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - Linux terminal program running in the background (Linux)

- Linux kernel VLAN study notes (Programming)

- Linux development management utility command (Linux)

- Eclipse distributed management using GitHub project development (Linux)

- ARM runtime environment built from scratch using QEMU emulator (Linux)

- Search Linux commands and files - which, whereis, locate, find (Linux)

- Linux Shell Understanding and Learning (Linux)

- Android judgment toward camera pictures (Programming)

- Understand the profound discussion of some of the options for wireless encryption (Linux)

- Using Maven to download Spring (Linux)

- Installation JDK 1.8 under CentOS7 (Linux)

- VMware virtual machine to install CentOS 6.2 (Linux)

- Use DB2 federated access Oracle (Database)

- Linux Basic Course: Install the software from source code (Linux)

- How ONLYOFFICE collaborative editing document on Linux (Linux)

- Making Linux root file system problems on-link library (Programming)

- Use HugePages optimize memory performance (Database)

- DDOS Attacks and Prevention (Linux)

- To configure parameter configuration and software installation and uninstallation under Linux (Linux)

- To help you easily protect the Linux System (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:      
 
- Use Linux firewall camouflage defense hacked (Linux)
- Erlang concurrency and foundation (Programming)
- Firewall Configuration Red Hat Enterprise Linux 4 (Linux)
- How to Install Node.js in CentOS 7 (Linux)
- Ora-1092: OPI colleague K aborting process --- killed by OO Well killer (Database)
- a virtual machine created migrated to host RHEL6.4 on Ubuntu 14.04 (Linux)
- Chromium Install Flash Official Guide (Linux)
- Use Docker containers (Linux)
- HTML5 Fundamentals study notes (Programming)
- Oracle conditional select statements and looping statements (Database)
- Python implementation restart the router (Programming)
- How to interactively create a Docker container (Server)
- Linux Learning --- disk partition / relational representation + mount (Linux)
- Linux (SUSE) mount NTFS mobile hard practice (Linux)
- Python KNN algorithm of actual realization (Programming)
- Java Class file format parsing (Programming)
- Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 in (Linux)
- Installation of JDK and Tomcat under Linux (CentOS) (Linux)
- PHP interview questions of design patterns (Programming)
- Oracle can not change the tablespace to backup mode in non-archive mode (Database)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.