Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - Ubuntu install image browser and manager Phototonic 1.6.17 (Linux)

- RPM package creation Getting Started (Linux)

- JavaScript common functions summary (Programming)

- OGG-03510 Problem (Database)

- Ubuntu install driver manager Mint Driver Manager and Device Driver Manager (Linux)

- Difference in MySQL VARCHAR and CHAR data format (Database)

- Deploy the project to the server from GitHub (Server)

- Two programs HAProxy + Heartbeat (note, the secondary server vip, normal HAProxy boot method) (Server)

- To install Gitolite in Ubuntu / Fedora / CentOS (Linux)

- Ubuntu and derivative users to install the system launcher SimDock 1.3 (Linux)

- Linux RPM (Linux)

- Jump table (skiplist) of code (Programming)

- Make full use of the Raspberry Pi SD card space (Linux)

- Forgot Linux root password (Linux)

- Text editing and viewing text Linux command (Linux)

- Linux mount command Detailed (Linux)

- Using 30 seconds to write a detailed analysis of garbage removal system (Linux)

- Ubuntu install code editor Sublime Text 3 (Linux)

- RedHat virtual machine to install VMware Tools (Linux)

- Limit the use of the request being Nginx Flood attack (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:      
 
- Java multi-threaded shared communications variables (Programming)
- To install and deploy Apache under the CentOS (Server)
- Install Xshell on Mac OS X (Linux)
- Disk Management LVM (Linux)
- Network Security Basics Linux command (Linux)
- C / C ++ various data types Conversion Summary (Programming)
- Automatic Clear date directory shell script (Linux)
- RedHat Performance Tuning (Server)
- Memcache explain in detail (Server)
- SecureCRT 7.0 Log Ubuntu 12.04 server via SSH service under Vmware (Server)
- AWK principles and commands and file input (Linux)
- Linux install and configure Heartbeat (Server)
- Linux SU command security Suggestions (Linux)
- Linux Getting Started Tutorial: How to set up a static MAC address on VMware ESXi virtual machine (Mobile)
- Ubuntu 15.04 installation Powercommands 2.0 (Linux)
- Linux System Getting Started Learning: compile and install ixgbe driver in Ubuntu or Debian (Linux)
- Installation and configuration of phpMyAdmin under CentOS (Database)
- Oracle 11.2.0.3 and MySQL5.6 DDL comparison (Database)
- How to use Linux iptables tool for network sharing (Linux)
- Implement binary search algorithm in C language (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.