user1300830
user1300830

Reputation: 83

What objects allowed in GAE Memcache

I am trying to understand what Objects can be stored in Java Memcache but not able to find direct answers.

What I had tried was storing a ConcurentHashMap in Memcache where the ConcurentHashMap has each value being another ConcurentHashMap upto 5 levels.

This was the design before and I wanted to make as less changes as necessary.

However, I found a weird problem:

java.lang.IllegalArgumentException: Cannot use as value: 'com.xx.xxxx@1a55d9d' at com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.serializeValue(AsyncMemcacheServiceImpl.java:283) at com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.doPut(AsyncMemcacheServiceImpl.java:516) at com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.put(AsyncMemcacheServiceImpl.java:591) at com.google.appengine.api.memcache.MemcacheServiceImpl.put(MemcacheServiceImpl.java:79)

I had embedded a ConcurrentHashMap inside a class and passed it to Memcache. With a normal ConcurrentHashMap as well I faced the same issue.

I looked into different forums, but could not find an answer to what objects can be stored in Memcache especially from java collections and objects like these (ConcurrentHashMap). What types of complex java Objects can I save in Memcache?

Another question that I have is, what happens when I deploy a new version again on GAE? Are the values previously stored in Memcache destroyed ?

Upvotes: 0

Views: 230

Answers (1)

Mark Doyle
Mark Doyle

Reputation: 4874

Memcache will typically allow any serializable objects. Classes will need to implement Serializable to have Java handle the serialization. In the case of storing collections or other data structures the objects within the data structure will also need to be serializable.

public class MyClass implements Serializable { }

All versions of your app share the same memcache. The cache is global and is shared across the application's frontend, backend, and all of its services and versions. See Appengine Memcache

Upvotes: 1

Related Questions