سؤال

I'm trying to cache a data row or tuple fetched from a SQL query into memcached, using the query as the key and the result set as the value.

At first I tried to insert a HashMap, runtime gave me IllegalArgumentException: Non-serializable object

Then I tried wrapping it in a class that is implementing Serializable, but runtime still throws the above exception.

So how do you insert a data tuple from a SQL query into MemCacheD?

هل كانت مفيدة؟

المحلول

The Non-serializable object exception is coming from an object inside the HashMap. HashMap itself is serializable but all objects being serialized need to be serailizable. This requirement cascades to all members of an object that are getting serialized.

Check classes of the keys and and values that are in the hashmap that is to be cached. If the objects are coming from your sql driver and are not serializable then you may need to copy their data into your own serializable objects.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top