That is I'm trying to but if I do something simple as
mCache.put(key, value);
System.err.println(mCache.get(key));
I get a null value.
-----Original Message-----
From: Tim Cronin [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 01, 2005 1:31 PM
To: JCS Users List
Subject: Cache Keys
I'm using and object as the cache key is there something special I have
to do?
Here is my key class
public class Key implements Serializable
{
/**
* the site
*/
private String mSite = null;
/**
* the page
*/
private String mPage = null;
/**
* the locale
*/
private String mLocale = null;
/**
* the component ID
*/
private String mComponent = null;
/***********************************************************************
******
* create new Key (used for purge)
*
* @param site the site
************************************************************************
*****/
public Key(String site)
{
mSite = site;
}
/***********************************************************************
******
* create new Key (used for purge)
*
* @param site the site
* @param page the page
************************************************************************
*****/
public Key(String site, String page)
{
mSite = site;
mPage = page;
}
/***********************************************************************
******
* create new Key (for page)
*
* @param site the site
* @param page the page
* @param locale the locale
************************************************************************
*****/
public Key(String site, String page, String locale)
{
mLocale = locale;
mPage = page;
mSite = site;
}
/***********************************************************************
******
* create new Key (for component key)
*
* @param k the key (for the page)
* @param component the component
************************************************************************
*****/
public Key(Key k, String component)
{
mSite = k.mSite;
mPage = k.mPage;
mLocale = k.mLocale;
mComponent = component;
}
/***********************************************************************
******
* Gets The component.
*
* @return Returns the component.
************************************************************************
*****/
public String getComponent()
{
return mComponent;
}
/***********************************************************************
******
* Gets The locale.
*
* @return Returns the locale.
************************************************************************
*****/
public String getLocale()
{
return mLocale;
}
/***********************************************************************
******
* Gets The page.
*
* @return Returns the page.
************************************************************************
*****/
public String getPage()
{
return mPage;
}
/***********************************************************************
******
* Gets The site.
*
* @return Returns the site.
************************************************************************
*****/
public String getSite()
{
return mSite;
}
/***********************************************************************
******
* get the xpath logic to use to filter cache options
*
* @return the xpath logic string
************************************************************************
*****/
public String getXPath()
{
StringBuffer buff = new StringBuffer();
buff.append("[EMAIL
PROTECTED]'").append(StringEscapeUtils.escapeJava(mSite)).appe
nd("'");
if (mPage != null)
{
buff.append(" and
@page='").append(StringEscapeUtils.escapeJava(mPage)).append("'");
}
buff.append("]");
return buff.toString();
}
/***********************************************************************
******
* @see java.lang.Object#equals(java.lang.Object)
************************************************************************
*****/
public boolean equals(Object o)
{
if (o instanceof Key)
{
return false;
}
if (this == o)
{
return true;
}
Key that = (Key) o;
return new EqualsBuilder()
.append(mSite, that.mSite)
.append(mPage, that.mPage)
.append(mLocale, that.mLocale)
.append(mComponent, that.mComponent)
.isEquals();
}
/***********************************************************************
******
* @see java.lang.Object#hashCode()
************************************************************************
*****/
public int hashCode()
{
return new HashCodeBuilder()
.append(mSite)
.append(mPage)
.append(mLocale)
.append(mComponent)
.toHashCode();
}
/***********************************************************************
******
* @see java.lang.Object#toString()
************************************************************************
*****/
public String toString()
{
return new ToStringBuilder(this)
.append("mSite", mSite)
.append("mPage", mPage)
.append("mLocale", mLocale)
.append("mComponent", mComponent)
.toString();
}
}
---------------------------------------------------------------------
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]