Package com.hierynomus.smbj.share
Class LeasedDirectoryCache
java.lang.Object
com.hierynomus.smbj.share.LeasedDirectoryCache
Per-leased-directory enumeration cache (spec 07). Stores the last full listing keyed by
(path, informationClass, searchPattern) and serves it on a repeat
list() while a
valid RH lease is held. Evicted synchronously when a lease break is observed (spec 06).
Correctness invariant: a cached enumeration is served only while a granted, un-broken RH
lease protects it; any break calls invalidateAll() before the next list()
can observe it. Only the default ("list everything") query is cacheable — any real
searchPattern bypasses the cache.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongNumber of populates, i.e.longNumber of cache hits served (test/diagnostic).voidEvict everything (the break/downgrade hook).static booleanisCacheable(String searchPattern) Only the default/empty search pattern (list everything) is cacheable.<I extends FileDirectoryQueryableInformation>
voidStore an unmodifiable snapshot.static void<I extends FileDirectoryQueryableInformation>
List<I> static longstatic long
-
Constructor Details
-
LeasedDirectoryCache
public LeasedDirectoryCache()
-
-
Method Details
-
totalHits
public static long totalHits() -
totalPopulates
public static long totalPopulates() -
resetStats
public static void resetStats() -
isCacheable
Only the default/empty search pattern (list everything) is cacheable. -
serve
public <I extends FileDirectoryQueryableInformation> List<I> serve(String path, Class<I> informationClass, String searchPattern) - Returns:
- the cached listing for the key, or
nullon a miss. Lock-free.
-
populate
public <I extends FileDirectoryQueryableInformation> void populate(String path, Class<I> informationClass, String searchPattern, List<I> listing) Store an unmodifiable snapshot. Caller MUST hold a valid RH lease. -
invalidateAll
public void invalidateAll()Evict everything (the break/downgrade hook). -
getServeHits
public long getServeHits()Number of cache hits served (test/diagnostic). -
getPopulates
public long getPopulates()Number of populates, i.e. real enumerations cached (test/diagnostic).
-