You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-users@jakarta.apache.org by an...@axa.com.au on 2004/02/23 01:11:01 UTC
Cache Key (Disk Cache - Indexed) -- How to make key persistent
Here is what I did:
1. Put Cache Item in disk cache
2. Shut down the server abruptly or normally
3. Try to get cache item
4. its null, disk file set to size 0KB
Indexed Disk Cache stores keys in memory, Is it possible to store it on
disk so that when I restart server and accesses Cache, I can retrieve
cache item?
Thanks,
Ankur
*********************************************************************************
Important Note
This email (including any attachments) contains information which is
confidential and may be subject to legal privilege. If you are not
the intended recipient you must not use, distribute or copy this
email. If you have received this email in error please notify the
sender immediately and delete this email. Any views expressed in this
email are not necessarily the views of AXA. Thank you.
*********************************************************************************
Re: Cache Key (Disk Cache - Indexed) -- How to make key persistent
Posted by Christian Kreutzfeldt <kr...@subshell.com>.
Hi!
> Indexed Disk Cache stores keys in memory, Is it possible to store it on
> disk so that when I restart server and accesses Cache, I can retrieve
> cache item?
It is possible and sometimes the Indexed Disk Cache does write the data
to the disk, but the more common case is that the data are not written to
disk! The reason seems to be a flag 'alive' which is set to false too early,
namely BEFORE all data should be written to disk. Unfortunately the
writing process heavily relies on that flag. I submitted the same bug at
least two times and someone else also found it, but there were no one
willing to fix that up to now.
Kind regards,
Christian Kreutzfeldt
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
RE: Cache returning unexpected items.
Posted by Aaron Smuts <aa...@wisc.edu>.
This sounds very strange. Are you sure the cache was returning the
wrong value? There is no way your program could have a multithreading
problem and switch up some entries? The cache passes objects by
reference--could you have tried to recycled some entry somewhere?
Aaron
> -----Original Message-----
> From: Matthew Cooke [mailto:mpcooke3@lineone.net]
> Sent: Monday, February 23, 2004 9:26 AM
> To: Turbine JCS Users List
> Subject: Cache returning unexpected items.
>
> This is probably a bit of a shot in the dark, but I'll ask on the off
> chance anyone has any ideas.
>
> Last week I replaced our "developed in house" caching solution with
JCS.
> JCS was configured with two LTCP caches and a DC. (LTCP1, LTCP2, DC)
>
> During testing the cache returned the same results as a our in house
> caching solution.
> So, we left it running on a subset of our production servers over the
> weekend.
>
> Unfortunately on saturday, possibly after restarting some of the
caches
> it appears that JCS started returning the wrong Value for a given Key.
> This was quite unfortunate to say the least, the cache contained
> commercially sensitive data. Customers started seeing other clients
> data. "clientName" was one of the properties we keyed on.
>
> We are keying on an object that basically wraps a java.util.hashtable
> which should serialize all it's data. I fail to see how under any
> circumstances JCS could return the wrong value
>
> Anyone have any ideas? We didn't see this behaviour during testing
> unfortunately.
>
> Matt.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
Re: Cache returning unexpected items.
Posted by Matthew Cooke <mp...@lineone.net>.
Aaron,
It's not strictly neccessary, although the keys are already tested and used in
another part of the system, so using strings would require a little more code and
testing - rather than a little less. I'll consider trying strings anyway. My primary
concern at the moment is trying to work out what went wrong last time before
redeploying changes to our production enviroment.
Cheers,
Matt.
Aaron Smuts wrote:
> I'm not sure why all this complexity is necessary. Can't you use
> something more efficient, like a simple _ delimited string for the key?
> The cache has built in hierarchical removal for keys in this form . . .
>
> How the items are retrieved is not exposed to the user of JCS. There is
> no interface that specifies how to make a complex key. Maybe there
> should be an interface or the keys should be restricted to strings. . .
> This is something to consider.
>
> Something along the lines of what you are doing should work, but I
> suggest that you use a string key if possible. It is more efficient and
> predictable.
>
> Aaron
>
>
>>-----Original Message-----
>>From: Matthew Cooke [mailto:mpcooke3@lineone.net]
>>Sent: Tuesday, February 24, 2004 10:07 AM
>>To: Turbine JCS Users List
>>Subject: Re: Cache returning unexpected items.
>>
>>Paulo,
>>
>>Ok :) sorry - I *nearly* included all the useful methods, but we also
>
> have
>
>>this
>>method on RealCacheKey
>>
>> public int hashCode() {
>> return myMultipartKey.hashCode();
>> }
>>
>>Sorry I didn't include this before.
>>
>>Matt,
>>
>>
>>paulo caroli wrote:
>>
>>>Hey Matt,
>>>
>>>Check this link:
>>>http://www.cafeaulait.org/course/week4/38.html
>>>
>>>"Anytime you override equals() you should also override hashCode().
>
> The
>
>>>hashCode() method should ideally return the same int for any two
>
> objects
>
>>>that compare equal and a different int for any two objects that
>
> don't
>
>>>compare equal, where equality is defined by the equals() method.
>
> This is
>
>>>used as an index by the java.util.Hashtable class. "
>>>
>>>Paulo
>>>
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: paulo caroli [mailto:pcaroli@corp.blah.com]
>>>Sent: Tuesday, February 24, 2004 10:46 AM
>>>To: 'Turbine JCS Users List'
>>>Subject: RE: Cache returning unexpected items.
>>>
>>>Matt,
>>>
>>>I advice you to test your key comparison to ensure it is working.
>>>For some cases you need to implement the public int hashCode()
>
> method as
>
>>>well as the public boolean equals(Object obj) method.
>>>Thanks,
>>>
>>>Paulo
>>>
>>>
>>>-----Original Message-----
>>>From: Matthew Cooke [mailto:mpcooke3@lineone.net]
>>>Sent: Tuesday, February 24, 2004 6:01 AM
>>>To: Turbine JCS Users List
>>>Subject: Re: Cache returning unexpected items.
>>>
>>>
>>>
>>>>How are you comparing the keys?
>>>>Thanks,
>>>>
>>>>Paulo
>>>
>>>
>>>Paulo,
>>>
>>>Maybe that is the problem. Does the key object need to be comparable
>
> or
>
>>>something?
>>>(appologies for long post - I've tried to include most of the
>
> relevant
>
>>key
>>
>>>related code)
>>>
>>>Here are the important parts of the key object we use:
>>>
>>>public class RealCacheKey implements CacheKey {
>>> private Collection myMultipartKey = new HashSet();
>>>
>>> public RealCacheKey(HttpServletRequest aServletRequest) {
>>> addURIParametersInto(myMultipartKey, aServletRequest);
>>> }
>>>
>>><...snip...>
>>>
>>> public static void addURIParametersInto(Collection aCollection,
>>>HttpServletRequest aRequest) {
>>> Enumeration names = aRequest.getParameterNames();
>>>
>>> while (names.hasMoreElements()) {
>>> String aKey = (String) names.nextElement();
>>> if (!isCacheBuster(aKey)) {
>>> String[] values =
>
> aRequest.getParameterValues(aKey);
>
>>> aCollection.add(new MapEntry(aKey,
>>
>>Arrays.asList(values)));
>>
>>> }
>>> }
>>> }
>>>
>>> private boolean equals(RealCacheKey another) {
>>> return myMultipartKey.equals(another.myMultipartKey);
>>> }
>>>
>>> public boolean equals(Object another) {
>>> return (another instanceof CacheKey) &&
>
> equals((RealCacheKey)
>
>>>another);
>>> }
>>><...snip...>
>>>}
>>>
>>>The cachekey interface extends serializable.
>>>The map entries are serializable and look like this:
>>>
>>>public class MapEntry implements java.util.Map.Entry, Comparable,
>>>Serializable {
>>> private static final String NULL = "null";
>>> private Object key;
>>> private Object value;
>>>
>>> public MapEntry(Object aKey, Object aValue) {
>>> super();
>>> this.key = (aKey == null) ? NULL : aKey;
>>> this.value = (aValue == null) ? NULL : aValue;
>>> }
>>>
>>><...snip...>
>>>
>>>
>>>Cheers,
>>>Matt.
>>>
>>>
>
> ---------------------------------------------------------------------
>
>>>To unsubscribe, e-mail:
>
> turbine-jcs-user-unsubscribe@jakarta.apache.org
>
>>>For additional commands, e-mail: turbine-jcs-user-
>>
>>help@jakarta.apache.org
>>
>>>
>>>
> ---------------------------------------------------------------------
>
>>>To unsubscribe, e-mail:
>
> turbine-jcs-user-unsubscribe@jakarta.apache.org
>
>>>For additional commands, e-mail: turbine-jcs-user-
>>
>>help@jakarta.apache.org
>>
>>>
>>>
> ---------------------------------------------------------------------
>
>>>To unsubscribe, e-mail:
>
> turbine-jcs-user-unsubscribe@jakarta.apache.org
>
>>>For additional commands, e-mail: turbine-jcs-user-
>>
>>help@jakarta.apache.org
>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail:
>
> turbine-jcs-user-unsubscribe@jakarta.apache.org
>
>>For additional commands, e-mail:
>
> turbine-jcs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
RE: Cache returning unexpected items.
Posted by Aaron Smuts <aa...@wisc.edu>.
I'm not sure why all this complexity is necessary. Can't you use
something more efficient, like a simple _ delimited string for the key?
The cache has built in hierarchical removal for keys in this form . . .
How the items are retrieved is not exposed to the user of JCS. There is
no interface that specifies how to make a complex key. Maybe there
should be an interface or the keys should be restricted to strings. . .
This is something to consider.
Something along the lines of what you are doing should work, but I
suggest that you use a string key if possible. It is more efficient and
predictable.
Aaron
> -----Original Message-----
> From: Matthew Cooke [mailto:mpcooke3@lineone.net]
> Sent: Tuesday, February 24, 2004 10:07 AM
> To: Turbine JCS Users List
> Subject: Re: Cache returning unexpected items.
>
> Paulo,
>
> Ok :) sorry - I *nearly* included all the useful methods, but we also
have
> this
> method on RealCacheKey
>
> public int hashCode() {
> return myMultipartKey.hashCode();
> }
>
> Sorry I didn't include this before.
>
> Matt,
>
>
> paulo caroli wrote:
> > Hey Matt,
> >
> > Check this link:
> > http://www.cafeaulait.org/course/week4/38.html
> >
> > "Anytime you override equals() you should also override hashCode().
The
> > hashCode() method should ideally return the same int for any two
objects
> > that compare equal and a different int for any two objects that
don't
> > compare equal, where equality is defined by the equals() method.
This is
> > used as an index by the java.util.Hashtable class. "
> >
> > Paulo
> >
> >
> >
> >
> > -----Original Message-----
> > From: paulo caroli [mailto:pcaroli@corp.blah.com]
> > Sent: Tuesday, February 24, 2004 10:46 AM
> > To: 'Turbine JCS Users List'
> > Subject: RE: Cache returning unexpected items.
> >
> > Matt,
> >
> > I advice you to test your key comparison to ensure it is working.
> > For some cases you need to implement the public int hashCode()
method as
> > well as the public boolean equals(Object obj) method.
> > Thanks,
> >
> > Paulo
> >
> >
> > -----Original Message-----
> > From: Matthew Cooke [mailto:mpcooke3@lineone.net]
> > Sent: Tuesday, February 24, 2004 6:01 AM
> > To: Turbine JCS Users List
> > Subject: Re: Cache returning unexpected items.
> >
> >
> >>How are you comparing the keys?
> >>Thanks,
> >>
> >>Paulo
> >
> >
> > Paulo,
> >
> > Maybe that is the problem. Does the key object need to be comparable
or
> > something?
> > (appologies for long post - I've tried to include most of the
relevant
> key
> > related code)
> >
> > Here are the important parts of the key object we use:
> >
> > public class RealCacheKey implements CacheKey {
> > private Collection myMultipartKey = new HashSet();
> >
> > public RealCacheKey(HttpServletRequest aServletRequest) {
> > addURIParametersInto(myMultipartKey, aServletRequest);
> > }
> >
> > <...snip...>
> >
> > public static void addURIParametersInto(Collection aCollection,
> > HttpServletRequest aRequest) {
> > Enumeration names = aRequest.getParameterNames();
> >
> > while (names.hasMoreElements()) {
> > String aKey = (String) names.nextElement();
> > if (!isCacheBuster(aKey)) {
> > String[] values =
aRequest.getParameterValues(aKey);
> > aCollection.add(new MapEntry(aKey,
> Arrays.asList(values)));
> > }
> > }
> > }
> >
> > private boolean equals(RealCacheKey another) {
> > return myMultipartKey.equals(another.myMultipartKey);
> > }
> >
> > public boolean equals(Object another) {
> > return (another instanceof CacheKey) &&
equals((RealCacheKey)
> > another);
> > }
> > <...snip...>
> > }
> >
> > The cachekey interface extends serializable.
> > The map entries are serializable and look like this:
> >
> > public class MapEntry implements java.util.Map.Entry, Comparable,
> > Serializable {
> > private static final String NULL = "null";
> > private Object key;
> > private Object value;
> >
> > public MapEntry(Object aKey, Object aValue) {
> > super();
> > this.key = (aKey == null) ? NULL : aKey;
> > this.value = (aValue == null) ? NULL : aValue;
> > }
> >
> > <...snip...>
> >
> >
> > Cheers,
> > Matt.
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-jcs-user-
> help@jakarta.apache.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-jcs-user-
> help@jakarta.apache.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: turbine-jcs-user-
> help@jakarta.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
Re: Cache returning unexpected items.
Posted by Matthew Cooke <mp...@lineone.net>.
Paulo,
Ok :) sorry - I *nearly* included all the useful methods, but we also have this
method on RealCacheKey
public int hashCode() {
return myMultipartKey.hashCode();
}
Sorry I didn't include this before.
Matt,
paulo caroli wrote:
> Hey Matt,
>
> Check this link:
> http://www.cafeaulait.org/course/week4/38.html
>
> "Anytime you override equals() you should also override hashCode(). The
> hashCode() method should ideally return the same int for any two objects
> that compare equal and a different int for any two objects that don't
> compare equal, where equality is defined by the equals() method. This is
> used as an index by the java.util.Hashtable class. "
>
> Paulo
>
>
>
>
> -----Original Message-----
> From: paulo caroli [mailto:pcaroli@corp.blah.com]
> Sent: Tuesday, February 24, 2004 10:46 AM
> To: 'Turbine JCS Users List'
> Subject: RE: Cache returning unexpected items.
>
> Matt,
>
> I advice you to test your key comparison to ensure it is working.
> For some cases you need to implement the public int hashCode() method as
> well as the public boolean equals(Object obj) method.
> Thanks,
>
> Paulo
>
>
> -----Original Message-----
> From: Matthew Cooke [mailto:mpcooke3@lineone.net]
> Sent: Tuesday, February 24, 2004 6:01 AM
> To: Turbine JCS Users List
> Subject: Re: Cache returning unexpected items.
>
>
>>How are you comparing the keys?
>>Thanks,
>>
>>Paulo
>
>
> Paulo,
>
> Maybe that is the problem. Does the key object need to be comparable or
> something?
> (appologies for long post - I've tried to include most of the relevant key
> related code)
>
> Here are the important parts of the key object we use:
>
> public class RealCacheKey implements CacheKey {
> private Collection myMultipartKey = new HashSet();
>
> public RealCacheKey(HttpServletRequest aServletRequest) {
> addURIParametersInto(myMultipartKey, aServletRequest);
> }
>
> <...snip...>
>
> public static void addURIParametersInto(Collection aCollection,
> HttpServletRequest aRequest) {
> Enumeration names = aRequest.getParameterNames();
>
> while (names.hasMoreElements()) {
> String aKey = (String) names.nextElement();
> if (!isCacheBuster(aKey)) {
> String[] values = aRequest.getParameterValues(aKey);
> aCollection.add(new MapEntry(aKey, Arrays.asList(values)));
> }
> }
> }
>
> private boolean equals(RealCacheKey another) {
> return myMultipartKey.equals(another.myMultipartKey);
> }
>
> public boolean equals(Object another) {
> return (another instanceof CacheKey) && equals((RealCacheKey)
> another);
> }
> <...snip...>
> }
>
> The cachekey interface extends serializable.
> The map entries are serializable and look like this:
>
> public class MapEntry implements java.util.Map.Entry, Comparable,
> Serializable {
> private static final String NULL = "null";
> private Object key;
> private Object value;
>
> public MapEntry(Object aKey, Object aValue) {
> super();
> this.key = (aKey == null) ? NULL : aKey;
> this.value = (aValue == null) ? NULL : aValue;
> }
>
> <...snip...>
>
>
> Cheers,
> Matt.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
RE: Cache returning unexpected items.
Posted by paulo caroli <pc...@corp.blah.com>.
Hey Matt,
Check this link:
http://www.cafeaulait.org/course/week4/38.html
"Anytime you override equals() you should also override hashCode(). The
hashCode() method should ideally return the same int for any two objects
that compare equal and a different int for any two objects that don't
compare equal, where equality is defined by the equals() method. This is
used as an index by the java.util.Hashtable class. "
Paulo
-----Original Message-----
From: paulo caroli [mailto:pcaroli@corp.blah.com]
Sent: Tuesday, February 24, 2004 10:46 AM
To: 'Turbine JCS Users List'
Subject: RE: Cache returning unexpected items.
Matt,
I advice you to test your key comparison to ensure it is working.
For some cases you need to implement the public int hashCode() method as
well as the public boolean equals(Object obj) method.
Thanks,
Paulo
-----Original Message-----
From: Matthew Cooke [mailto:mpcooke3@lineone.net]
Sent: Tuesday, February 24, 2004 6:01 AM
To: Turbine JCS Users List
Subject: Re: Cache returning unexpected items.
> How are you comparing the keys?
> Thanks,
>
> Paulo
Paulo,
Maybe that is the problem. Does the key object need to be comparable or
something?
(appologies for long post - I've tried to include most of the relevant key
related code)
Here are the important parts of the key object we use:
public class RealCacheKey implements CacheKey {
private Collection myMultipartKey = new HashSet();
public RealCacheKey(HttpServletRequest aServletRequest) {
addURIParametersInto(myMultipartKey, aServletRequest);
}
<...snip...>
public static void addURIParametersInto(Collection aCollection,
HttpServletRequest aRequest) {
Enumeration names = aRequest.getParameterNames();
while (names.hasMoreElements()) {
String aKey = (String) names.nextElement();
if (!isCacheBuster(aKey)) {
String[] values = aRequest.getParameterValues(aKey);
aCollection.add(new MapEntry(aKey, Arrays.asList(values)));
}
}
}
private boolean equals(RealCacheKey another) {
return myMultipartKey.equals(another.myMultipartKey);
}
public boolean equals(Object another) {
return (another instanceof CacheKey) && equals((RealCacheKey)
another);
}
<...snip...>
}
The cachekey interface extends serializable.
The map entries are serializable and look like this:
public class MapEntry implements java.util.Map.Entry, Comparable,
Serializable {
private static final String NULL = "null";
private Object key;
private Object value;
public MapEntry(Object aKey, Object aValue) {
super();
this.key = (aKey == null) ? NULL : aKey;
this.value = (aValue == null) ? NULL : aValue;
}
<...snip...>
Cheers,
Matt.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
RE: Cache returning unexpected items.
Posted by paulo caroli <pc...@corp.blah.com>.
Matt,
I advice you to test your key comparison to ensure it is working.
For some cases you need to implement the public int hashCode() method as
well as the public boolean equals(Object obj) method.
Thanks,
Paulo
-----Original Message-----
From: Matthew Cooke [mailto:mpcooke3@lineone.net]
Sent: Tuesday, February 24, 2004 6:01 AM
To: Turbine JCS Users List
Subject: Re: Cache returning unexpected items.
> How are you comparing the keys?
> Thanks,
>
> Paulo
Paulo,
Maybe that is the problem. Does the key object need to be comparable or
something?
(appologies for long post - I've tried to include most of the relevant key
related code)
Here are the important parts of the key object we use:
public class RealCacheKey implements CacheKey {
private Collection myMultipartKey = new HashSet();
public RealCacheKey(HttpServletRequest aServletRequest) {
addURIParametersInto(myMultipartKey, aServletRequest);
}
<...snip...>
public static void addURIParametersInto(Collection aCollection,
HttpServletRequest aRequest) {
Enumeration names = aRequest.getParameterNames();
while (names.hasMoreElements()) {
String aKey = (String) names.nextElement();
if (!isCacheBuster(aKey)) {
String[] values = aRequest.getParameterValues(aKey);
aCollection.add(new MapEntry(aKey, Arrays.asList(values)));
}
}
}
private boolean equals(RealCacheKey another) {
return myMultipartKey.equals(another.myMultipartKey);
}
public boolean equals(Object another) {
return (another instanceof CacheKey) && equals((RealCacheKey)
another);
}
<...snip...>
}
The cachekey interface extends serializable.
The map entries are serializable and look like this:
public class MapEntry implements java.util.Map.Entry, Comparable,
Serializable {
private static final String NULL = "null";
private Object key;
private Object value;
public MapEntry(Object aKey, Object aValue) {
super();
this.key = (aKey == null) ? NULL : aKey;
this.value = (aValue == null) ? NULL : aValue;
}
<...snip...>
Cheers,
Matt.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
Re: Cache returning unexpected items.
Posted by Matthew Cooke <mp...@lineone.net>.
> How are you comparing the keys?
> Thanks,
>
> Paulo
Paulo,
Maybe that is the problem. Does the key object need to be comparable or something?
(appologies for long post - I've tried to include most of the relevant key related code)
Here are the important parts of the key object we use:
public class RealCacheKey implements CacheKey {
private Collection myMultipartKey = new HashSet();
public RealCacheKey(HttpServletRequest aServletRequest) {
addURIParametersInto(myMultipartKey, aServletRequest);
}
<...snip...>
public static void addURIParametersInto(Collection aCollection,
HttpServletRequest aRequest) {
Enumeration names = aRequest.getParameterNames();
while (names.hasMoreElements()) {
String aKey = (String) names.nextElement();
if (!isCacheBuster(aKey)) {
String[] values = aRequest.getParameterValues(aKey);
aCollection.add(new MapEntry(aKey, Arrays.asList(values)));
}
}
}
private boolean equals(RealCacheKey another) {
return myMultipartKey.equals(another.myMultipartKey);
}
public boolean equals(Object another) {
return (another instanceof CacheKey) && equals((RealCacheKey) another);
}
<...snip...>
}
The cachekey interface extends serializable.
The map entries are serializable and look like this:
public class MapEntry implements java.util.Map.Entry, Comparable, Serializable {
private static final String NULL = "null";
private Object key;
private Object value;
public MapEntry(Object aKey, Object aValue) {
super();
this.key = (aKey == null) ? NULL : aKey;
this.value = (aValue == null) ? NULL : aValue;
}
<...snip...>
Cheers,
Matt.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
RE: Cache returning unexpected items.
Posted by paulo caroli <pc...@corp.blah.com>.
Matt,
How are you comparing the keys?
Thanks,
Paulo
-----Original Message-----
From: Matthew Cooke [mailto:mpcooke3@lineone.net]
Sent: Monday, February 23, 2004 10:26 AM
To: Turbine JCS Users List
Subject: Cache returning unexpected items.
This is probably a bit of a shot in the dark, but I'll ask on the off
chance anyone has any ideas.
Last week I replaced our "developed in house" caching solution with JCS.
JCS was configured with two LTCP caches and a DC. (LTCP1, LTCP2, DC)
During testing the cache returned the same results as a our in house
caching solution.
So, we left it running on a subset of our production servers over the
weekend.
Unfortunately on saturday, possibly after restarting some of the caches
it appears that JCS started returning the wrong Value for a given Key.
This was quite unfortunate to say the least, the cache contained
commercially sensitive data. Customers started seeing other clients
data. "clientName" was one of the properties we keyed on.
We are keying on an object that basically wraps a java.util.hashtable
which should serialize all it's data. I fail to see how under any
circumstances JCS could return the wrong value
Anyone have any ideas? We didn't see this behaviour during testing
unfortunately.
Matt.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org
Cache returning unexpected items.
Posted by Matthew Cooke <mp...@lineone.net>.
This is probably a bit of a shot in the dark, but I'll ask on the off
chance anyone has any ideas.
Last week I replaced our "developed in house" caching solution with JCS.
JCS was configured with two LTCP caches and a DC. (LTCP1, LTCP2, DC)
During testing the cache returned the same results as a our in house
caching solution.
So, we left it running on a subset of our production servers over the
weekend.
Unfortunately on saturday, possibly after restarting some of the caches
it appears that JCS started returning the wrong Value for a given Key.
This was quite unfortunate to say the least, the cache contained
commercially sensitive data. Customers started seeing other clients
data. "clientName" was one of the properties we keyed on.
We are keying on an object that basically wraps a java.util.hashtable
which should serialize all it's data. I fail to see how under any
circumstances JCS could return the wrong value
Anyone have any ideas? We didn't see this behaviour during testing
unfortunately.
Matt.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-user-help@jakarta.apache.org