withAdapter method

DVCacheView withAdapter(
  1. DVCacheAdapter adapter
)

The same four calls on adapter instead of the configured store.

dartvel.cache sets the store DV.Cache uses; this switches store in code, for one part of an application that needs another:

final DVCacheView sessions = DV.Cache.withAdapter(
  DVMemcachedCacheAdapter(host: 'cache.internal'),
);
await sessions.set('k', 'v', ttl: const Duration(minutes: 5));

Every call goes to adapter and never to the configured store. Tags and the shared compute are kept per adapter, so deleting a DVCacheTag on one store leaves another's entries alone, and two views of one adapter are one cache.

Implementation

DVCacheView withAdapter(DVCacheAdapter adapter) => _DVAdapterCache(adapter);