Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java by Spy Memcached to cache data     - How Mutt mail client to use cipher text password (Linux)

- File encryption and decryption of Linux security mechanisms (Linux)

- Windows environment Android Studio v1.0 Installation Guide (Linux)

- Android judgment toward camera pictures (Programming)

- MySQL time field based partitioning scheme summary (Database)

- Linux netstat command to get started (Linux)

- ogg Oracle to SQL Server 2005 to achieve synchronization (Database)

- Hadoop safe hftp (Server)

- Installation and use GAMIT / GLOBK Software (Linux)

- Linux Log (Linux)

- MongoDB Study Notes (1) - Install MongoDB on Windows systems (Database)

- xCAT error Unable to dispatch hierarchical sub-command to NORESOLUTION: 3001 (Linux)

- Linux file permissions and access modes (Linux)

- Volatile keyword in C language understanding (Programming)

- Ubuntu derivative version of the user and how to install SmartGit / HG 6.0.0 (Linux)

- History of the most complex validation e-mail address regular expression (Linux)

- Ubuntu install video playback software SMPlayer 14.9.0.7042 (Linux)

- In Debian 4.3 compiler under Linux-2.6.28 kernel Summary (Programming)

- Oracle can not change the tablespace to backup mode in non-archive mode (Database)

- Linux 6 use UDEV binding shared storage (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 JMS listener Oracle AQ, trigger the execution of Java programs in the database changes (Database)
- Ubuntu 14.04 install Nmap 6.46.1 (Linux)
- Oracle Database import and export combat (Database)
- Java gets the current system time System.currentTimeMillis () (Programming)
- Use Makeself Create installation file (Linux)
- hexdump Linux command (Linux)
- C # Future: Tracking null reference (Programming)
- Linux kernel boot to retain large memory method summary (Linux)
- Recovery from MySQL master data consistency summary (Database)
- Linux see whether there is a hacker program (Linux)
- PHP call a Python program (Programming)
- C ++ 11 smart pointers (Programming)
- On the design of Oracle database backup (Database)
- HashMap in Android and Java different implementations (Programming)
- Use top to monitor the remote server (Server)
- Linux MultiPath software implementation instructions (Linux)
- Linux Shell Understanding and Learning (Linux)
- Bootable ISO image using GRUB (Linux)
- Ubuntu 14.04 compile RT288x_SDK / toolchain / squashfs3.2-r2 Error (Linux)
- Nginx version of helloworld (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.