T
timasmith
Hi,
Are there any standard caching algorithms for method calls.
I setup a scheme which works, but I hate to reuse it if there is
something better.
Essentially what I do is keep a Hashtable with the key the
concatenated, delimeted method name and parameters.
For example
public Object getStaticReference(int i, int j) {
String key = getKey(i,j);
if (hashtable contains key) {
return object from hashtable;
else
call method, store and return object
}
private String getKey(params...) {
String key = getCallingMethodName() + ":" + i + ":" + j;
return key;
}
What do you think?
thanks
Tim
Are there any standard caching algorithms for method calls.
I setup a scheme which works, but I hate to reuse it if there is
something better.
Essentially what I do is keep a Hashtable with the key the
concatenated, delimeted method name and parameters.
For example
public Object getStaticReference(int i, int j) {
String key = getKey(i,j);
if (hashtable contains key) {
return object from hashtable;
else
call method, store and return object
}
private String getKey(params...) {
String key = getCallingMethodName() + ":" + i + ":" + j;
return key;
}
What do you think?
thanks
Tim