Class LeasedDirectoryCache

java.lang.Object
com.hierynomus.smbj.share.LeasedDirectoryCache

public class LeasedDirectoryCache extends Object
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 Details

    • LeasedDirectoryCache

      public LeasedDirectoryCache()
  • Method Details

    • totalHits

      public static long totalHits()
    • totalPopulates

      public static long totalPopulates()
    • resetStats

      public static void resetStats()
    • isCacheable

      public static boolean isCacheable(String searchPattern)
      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 null on 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).