FYI I implement Serializable just by adding 'implements
java.io.Serializable'. I let java take care of the serialVersionUID,
etc. Works very well for me, and it's one less thing to keep track of :)
Bret Schuhmacher wrote:
Niall,
Thanks for the reply. I do appreciate your time. However, I did find
that the minute I implemented Serializable and added just a single line
of code to my object to complete the Serializable implementation:
static final long serialVersionUID = 1;
everything started working. Apparently the objects you cache, even if
you never plan to let the object leave your JVM, have to be
Serializable.
Thanks again for the reply!
Rgds,
Bret
-----Original Message-----
From: Niall Gallagher [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2008 6:25 AM
To: JCS Users List
Subject: RE: Really stupid question - can I cache any random object?
Hi Bret,
*As far as I know* (-caveat!) your object doesn't need to be
serializable if you are just using the memory cache. So you can cache
any random object. It needs to be serializable if it will ever leave
the JVM however - so if you have configured any kind of disk caching
for example, your object would need to be serializable so it can be
moved from the JVM out to disk. I think in the examples on the web
pages configure a disk cache.
Try a minimal ccf file like this:
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttribu
tes
jcs.default.cacheattributes.MaxObjects=10000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memor
y.lru.LRUMemoryCache
jcs.default.cacheattributes.UseMemoryShrinker=false
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.IsLateral=false
jcs.default.elementattributes.IsRemote=false
jcs.default.elementattributes.IsSpool=false
Regards,
Niall
On Tue, 2008-07-08 at 23:29 -0500, Bret Schuhmacher wrote:
No, just an object. I thought you could cache anything (the little
docs I found just showed "Object"). But being serializable makes
sense now that I think about it. Is this required for memory
caching,
too, though? I've got the most minimal memory cache set up
(cache.ccf
copied directly from the web pages). I'll change my objects and see
what happens. Thanks for the quick response!! :-)
Rgds,
Bret
-----Original Message-----
From: Michael Toback [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2008 12:17 AM
To: JCS Users List
Subject: RE: Really stupid question - can I cache any random
object?
Silly question about your stupid question. Is your object
serializable?
-----Original Message-----
From: Bret Schuhmacher [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2008 9:09 PM
To: jcs-users@jakarta.apache.org
Subject: Really stupid question - can I cache any random object?
Can I cache *any* object? I get exceptions when I attempt to
cache
objects I've created, although I can cache simple objects like
Strings.
Unfortunately cache.put(String foo, myCustomObject bar) doesn't
tell
me
much more than the name of the class I'm trying to cache (i.e.
"myCustomObject"). It doesn't tell me why it threw the exception,
it just prints a stacktrace. Like I said - it all works fine if I
do
this:
cache.put("foo", "bar"), but if I do cache.put("foo", new
myCustomObject()) it will fail. I've even cast myCustomObject
back
to Object, but it still doesn't like it. Any way to get more
verbose messages out of the JCS code instead of just ERROR level?
Thanks,
Bret
-------------------------------------------------------------------
-
- To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
The information transmitted herewith is sensitive information
of
Chordiant Software or its customers and is intended only for use
to
the
individual or entity to which it is addressed. If the reader of
this
message is not the intended recipient, you are hereby notified
that
any
review, retransmission, dissemination, distribution, copying or
other use of, or taking of any action in reliance upon, this
information is strictly prohibited. If you have received this
communication in error, please contact the sender and delete the
material from your computer.
-------------------------------------------------------------------
-
- To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]