On 21 Oct 2010, at 07:06, 이희승 (Trustin Lee) wrote:
<SNIP />
> better names?
>
> cache.asVoid().remove();
> cache.disableFetch().remove();
>
cache.thisIsToDisableReturnValuesAndMakeSureYouWonTUseItAndYesTheAPIAuthorWasHackingInAPubInCaseYouWondered().remove();
To avoid the overhead of setting frequently used flags, I'd suggest
these flag methods to return a decorated or duplicated Cache instance
with updated default flags.
Cache myCache;
myCache = cache.withFlags(SKIP_REMOTE_LOOKUP, SKIP_CACHE_LOAD, ...);
myCache.remove();
A user could even have multiple Cache instances that decorates the same
cache with different flags.
But wait, don't we already have a similar one in AdvancedCache? It
seems stateful unlike my suggestion though. If it can be stateless like
I suggested, I think it could be moved up to Cache.
Well the whole purpose of making it stateful is to enable builder-style application of
flags to any and all Cache API calls.
Sanne's approach does make sense, for certain frequently-used flag patterns provide a
helper API which is essentially cache-like, and makes calls to the cache with appropriate
flags each time. And in the case of suppressing return values, this makes the most sense
since this can be modelled in the API via method return types.
This helper API can be cached too, e.g.:
NoReturnCache nrc = cache.asNoReturnCache();
nrc.put(k, v); // returns void, and adds relevant flags to cache
The tough bit is, what do you call this? ;)
Cheers
--
Manik Surtani
manik(a)jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org