A slight enhancement to the proposed IKeyedDataCache interface (overloading
the removeKeyedData method) :
public interface IKeyedDataCache {
/**
* Puts an keyed data to the cache.
* All key indexes will be updated.
*/
public void putKeyedData(IKeyedData data);
/**
* Gets an keyed data from the cache using the given key index.
*/
public IKeyedData getKeyedData(Serializable key, int idx);
/**
* Removes a keyed data from the cache using the given key index.
* All key indexes of the keyed data will be updated.
*/
public boolean removeKeyedData(Serializable key, int idx);
/**
* Removes a keyed data from the cache.
* All key indexes of the keyed data will be updated.
*/
public boolean removeKeyedData(IKeyedData data);
}
Hanson
> -----Original Message-----
> From: Hanson Char [mailto:[EMAIL PROTECTED]
> Sent: Saturday, July 19, 2003 6:16 AM
> To: 'Turbine JCS Users List'
> Subject: RE: composite keys and cache entries keys retrieval
>
>
> Imagine if one can have multiple-key supports for an object put to the
> cache, one can then have, say, a primary key of
> username+pageid, a secondary
> key of pageid+username. Now one can then invalidate all
> pageid of a given
> username via the primary composite key, and invalidate all
> user of a given
> pageid via the secondary composite key.
>
> Sometimes when we put a data value to the cache, such data
> value needs to be
> accessed via more than one key paths. Here is an idea for
> multi-key cached
> data support.
>
> Consider the interfaces:
> // Base interface for I2KeyData and INKeyData
> public interface IKeyedData extends Serializable {
> /** Returns the primary key used to access this cached data. */
> public Serializable getPrimaryKey();
> }
> // implemented by the multi-key data object for 2 key paths
> public interface I2KeyData extends IKeyedData {
> /** Returns the secondary key used to access this cached data. */
> public Serializable getSecondKey();
> }
> // implemented by the multi-key data object for 2+ key paths
> public interface INKeyData extends IKeyedData {
> /**
> * Returns all the keys used to access this cached data.
> * Note that key[0] must be the primary; and key[1], if
> any, must be the
> secondary key, etc.
> */
> public Serializable[] getKeyArray();
> }
>
> // implemented by the cache service provider (ie the cache system)
> public interface IKeyedDataCache {
> /**
> * Puts an keyed data to the cache.
> * All key indexes will be updated.
> */
> public void putKeyedData(IKeyedData data) throws IOException;
> /**
> * Gets an keyed data from the cache using the given key index.
> */
> public IKeyedData getKeyedData(Serializable key, int idx) throws
> IOException;
> /**
> * Removes a keyed data from the cache using the given key index.
> * All key indexes of the keyed data will be updated.
> */
> public boolean removeKeyedData(Serializable key, int idx) throws
> IOException;
> }
>
> Now to have multiple-key support, a data object can implement
> either the
> I2KeyData (for 2 keys) or INKeyData for 2+ keys. The
> important point is the
> implementation of the cache service provider should be done
> in such a way
> that putting or removing a multi-key data object to/from the
> cache via any
> key index will automatically update all keyed indexes (and in
> an atomic
> way).
>
> Hanson
>
> -----Original Message-----
> From: Hanson Char [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 11, 2003 8:11 AM
> To: 'Turbine JCS Users List'
> Subject: RE: composite keys and cache entries keys retrieval
>
>
> >in memory
>
> should be in the cache system, not necessarily in memory.
>
> -----Original Message-----
> From: Hanson Char
> Sent: Friday, July 11, 2003 8:10 AM
> To: 'Turbine JCS Users List'
> Subject: RE: composite keys and cache entries keys retrieval
>
>
> This sounds like a cache as relational database feature to
> me, in that when
> a cache is created, the "schema" of the cache can be specified so that
> multiple "indexes" to each cache item can be automatically
> updated by the
> cache provider code when items are add/update/delete to the
> specific cache.
>
> If such feature is available, one can retrieve a cache item
> not only via 1
> key (composite or not) but via other "candidate keys" as
> well. Yet there
> will exist only 1 copy of cache item in memory at all time.
>
> Hanson
>
> -----Original Message-----
> From: Fulco Houkes [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 11, 2003 5:28 AM
> To: JCS user mailinglist
> Subject: composite keys and cache entries keys retrieval
>
>
>
> Hi,
>
> (Sorry for this cross-posting, I noticed I send it to the
> wrong mailing
> list. My appologizes.)
>
> I'm try to use a composite key for all the cache entries; the
> composite key
> is combination of a pageID and a username. I need to be able
> to invalidate
> all the cache entries related to a specific pagesID as well
> as all the cache
> entries related to a username independently.
>
> I tried to use groups for this purpose, but it seems the entries are
> duplicated into the different groups, so it's not solving my
> problem. I've
> been looking for using the ":" hierarchy features, but the
> "very-light"
> documentation does present much on the subject, and I could not remove
> entries using the pattern ":"+ myKey +":". As far as I
> understood it, it's
> only possible to use this functionality with the myKey+":" pattern.
>
> Finally I opted to retrieve all the cache entries keys and
> filter myself the
> entries to be invalidated. But I could not found any method
> (from the JCS
> class) returning a Set/Enumeration/... of keys of all the the
> cache entries.
> The IMemoryCache interface has a getKeyArray() method, which
> does the job,
> but this method is not used within the inherited classes.
>
> Does anyone know how to retrieve the keys of all the entries
> present in the
> cache, without having to change the source code?
>
> Thanks a lot.
> Fulco Houkes
>
Initializing and updating ARGUS models is now as simple as navigating to
your favorite website. With ARGUS for Yardi(tm) you can quickly and easily
export comprehensive property, tenant and financial data from within Yardi
Enterprise or Voyager to create new ARGUS models or update existing ones.
Visit www.argusforyardi.com <http://www.argusforyardi.com> to request a
Demo CD-ROM, take a brief survey and be entered into a drawing to win a
Canon Powershot digital camera.
NOTICE: This communication contains information which is confidential to
Realm Business Solutions, Inc. or its subsidiary ("Realm"). If you are not
the intended recipient of this communication, please delete and destroy all
copies. If you are the intended recipient of this communication, you should
not copy, disclose or distribute this communication without Realm's
authority. Any views expressed in this communication are those of the
individual sender, except where the sender specifically states them to be
Realm's views. Except as required by law, Realm does not represent, warrant
or guarantee that the integrity of this communication has been maintained
nor that the communication is free of errors, virus, interception or
interference.