views:

40

answers:

1

The following exception is logged when data is put into the cache.

com.google.appengine.api.memcache.stdimpl.GCacheException: Policy prevented put operation

The data which is stored in the cache:

Map<String, List<Dependents>> dependentMap = new HashMap<String,List<Dependents>>();

In the map key will be an ID and for each ID there will be 0 or more objects (max 5 objects).

The map size is:

dependentMap.size() = 1500 approximately

Policy has been set to MemcacheService.SetPolicy.SET_ALWAYS, which is the default.

It was working fine but problem started when cache was cleared by calling the clear() method.

What is the reason and how do I solve the problem?

A: 

If dependentMap.size() is 1500 and each list has up to 5 objects, then you're storing up to 7500 objects in a single data structure, correct? It is probably the case that, with your data + the internal data representation that Java maintains, this Map is larger than 1MB.

Per the Google App Engine quotas/limitations, you cannot store any data structure larger than 1MB into memcache or into the datastore. This is the reason you are getting the Exception -- Google is not allowing this Map to be inserted into Memcache because of its size. I don't think calling clear() has anything to do with your problem.

Travis J Webb
also i tried storing 30 map in the cache by splitting 1500 into 50 but then also the put fails. even for 50 x 5 = 250 objects it is failing after few put operation. why ?
Sreekanth
Well, how large are the objects?
Travis J Webb
sorry, yes it was exceeding the 1mb limit. thanks
Sreekanth