Ok,
But this code is not very useful, It can be an SoftReference usage example.
It is better to implement java.util.Map interface if simplestore is kind of
cache not Storage.
It is some kind SoftMap implementation in commons collections, but this
class is not meaningful,
because use public method "purge()" to clear expired entries from map by
iterating keys.
But idea in commons to implement SoftMap is good, java.util.WeakHashMap is
not very useful for cache and more
transparent. JispFilesystemStore can be implemented this way too.
You can remove StoreJanitor it can help in some cases, but in the most
cases it is disadvantage for simplestore.
I think it useful to write documentation for this cache, add examples and
true tests( test in MemoryStore main method is not solution). It must be
documented Store advantages and disadvantages. May english
is not good to write documentation, it is readonly :)
You can document this way :
Advantages for MRUMemoryStore:
1. Speed for write operations.
....................................
Disadvantages:
1. It can't be used for memory sensetive application,
because it removes enties form Cache, not from memory.
...........................................
Advantages for MemoryStore:
1. Speed for read operations.
...........................................
Disadvantages:
1. Does not work if GC is dissabled or keys have strong references on values.
.........................................................
Good candidate for example is javax.servlet.http.HttpSession implementation :
public class PersistentHttpSession implements
javax.servlet.http.HttpSession{
.....................................
public PersistentHttpSession( javax.servlet.http.HttpSession
session,Store store){
this.session = session;
this.store = store;
}
public void setAttribute(String key,Object value){
store.store( new KeyPair(session.getId(),key),value);
// it is answer why KeyPair is useful. You can use new String(
session.getId() +" somethig to separate "+ key ) here,
// but this will not work for all types of keys and all cases
}
........................................................................
}
At 09:45 PM 1/15/2002 +0100, you wrote:
>Hi Juozas,
>I booked in your two classes as are. I only did
>some code formating.
>
><Could you do me one favour. If you like to contribute
>to this subproject (and I hope so), can you please
>use the Jakarta Code Formating rules. This issue
>caused some flame wars in the past and I don't
>want to repeat it! It's for your self protection ;-)>
I use Ctrl+Shift+F in NetBeans to format code, may this code formater is
not the
best, or I forgot to press this combination.
Do you use some kind of code formater in jakarta ?
>If you want to progress on your (all) classes then
>send me patches with the diff -u format.
>
>I hope I didn't blame you!
>
>Cheers
> Gerhard
>
>
>
>--
>To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>