Comments (2)
Modified the code AscIIClient.java as the up mentioned, it may occuer other error: set Object to memcached,like ArrayList Object,it can't be getted correcttly.
from memcached-java-client.
Hi weiqinyang,
I try to store and get Java object with array list type, and our client works correctly.
The following is my test case:
package com.schooner.MemCached;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.danga.MemCached.MemCachedClient;
import com.danga.MemCached.SockIOPool;
public class Test {
public static final class TestClass implements Serializable {
private static final long serialVersionUID = -6676639726514578903L;
private String field1;
private String field2;
private Integer field3;
public TestClass(String field1, String field2, Integer field3) {
this.field1 = field1;
this.field2 = field2;
this.field3 = field3;
}
public String getField1() {
return this.field1;
}
public String getField2() {
return this.field2;
}
public Integer getField3() {
return this.field3;
}
public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof TestClass))
return false;
TestClass obj = (TestClass) o;
return ((this.field1 == obj.getField1() || (this.field1 != null && this.field1.equals(obj.getField1())))
&& (this.field2 == obj.getField2() || (this.field2 != null && this.field2.equals(obj.getField2()))) && (this.field3 == obj
.getField3() || (this.field3 != null && this.field3.equals(obj.getField3()))));
}
}
public static void main(String[] args) throws Exception {
String servers = System.getProperty("memcached.host");
String[] serverlist = servers.split(",");
// initialize the pool for memcache servers
SockIOPool pool = SockIOPool.getInstance("test");
pool.setBufferSize(3 * 1024 * 1024);
pool.setServers(serverlist);
pool.initialize();
MemCachedClient mc = new MemCachedClient("test");
List<TestClass> list = new ArrayList<TestClass>();
for (int i = 0; i < 10; i++) {
list.add(new TestClass("value" + i, "value" + i, i));
}
mc.set("TestClass", list);
List<TestClass> ret = (List<TestClass>)mc.get("TestClass");
for (int i = 0; i < 10; i++) {
System.out.println(list.get(i).getField1());
}
}
}
Could you give a try and update your feedback?
Meng Li
from memcached-java-client.
Related Issues (20)
- Issue number 35 not fixed properly HOT 1
- Binary and Ascii clients together in one application
- 2.6.3 version:java.lang.OutOfMemoryError: Direct buffer memory
- Update code from maven (versions 3.*)
- Memcached信息过期的问题 HOT 1
- the return value of statsCacheDump() in BinaryClient
- why we dont have getExpiryTime(key) method?
- The flush_all method is working on the wrong way
- Add a license to the repo HOT 1
- nio下超时问题
- when ClassNotFoundException is thrown , a memory leak will happen after many times of get() operation.
- how to confirm a key exit and not to deserialization it
- Memcached client throwing NullPointerException
- java.lang.VerifyError: Bad type on operand stack
- Does this client support auth with password?
- java.io.IOException: Connection timed out HOT 1
- exception thrown while writing bytes to server on set HOT 1
- Memcache Client returns null even when cache is hit.
- Memcached self maintenance
- Cache client not honoring Expiry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from memcached-java-client.