Class WriteCache

java.lang.Object
com.iizix.WriteCache

public final class WriteCache extends Object
This class is used to handle writing strings to the cache used from the server to the client in transactions.

Threading. On the server, appending to a SendTransaction happens on the WorkerThread. More than one grab at a time therefore means nested or overlapping transactions on that SAME thread, never concurrent threads. Paths that run off the worker, the special start-up ones, append their strings with SendTransaction.appendString(String,boolean) and false, i.e. without this cache. The four synchronized(grabs) blocks are belt and braces and no claim of general thread safety: isCached reads the table outside them and addString puts into it outside them, which is harmless on one thread and would not be on two.

Author:
Christopher Mindus
See Also:
  • Constructor Details

    • WriteCache

      public WriteCache()
      Creates the write cache initialized to hold a defined maximum amount of strings. The default values for the cache are used, i.e. maxCount=700, minLength=7, maxLength=200.
    • WriteCache

      public WriteCache(int maxCount, int minLength, int maxLength)
      Creates the write cache initialized to hold a defined maximum amount of strings.
      Parameters:
      maxCount - Maximum count of strings in the cache.
      minLength - The minimum length of a string in the cache.
      maxLength - The maximum length of a string in the cache.
  • Method Details

    • dumpCache

      public String dumpCache(String indent)
      Dumps the cache.
      Parameters:
      indent - The indent for each line after the header, i.e. all lines listing cached items.
      Returns:
      The dumped cache.