ResourceCache (Apache Tomcat 7.0.96 API Documentation)

org.apache.naming.resources

## Class ResourceCache

- java.lang.Object
- - org.apache.naming.resources.ResourceCache

-     public class ResourceCache
      extends java.lang.Object

  Implements a special purpose cache.
  Author:
    Remy Maucherat

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected long` | `accessCount` Number of accesses to the cache.
    `protected CacheEntry[]` | `cache` Cache.
    `protected int` | `cacheMaxSize` Max size of resources which will have their content cached.
    `protected int` | `cacheSize` Current cache size in KB.
    `protected long` | `desiredEntryAccessRatio` Entry hit ratio at which an entry will never be removed from the cache.
    `protected long` | `hitsCount` Number of cache hits.
    `protected int` | `maxAllocateIterations` Max amount of removals during a make space.
    `protected java.util.HashMap<java.lang.String,CacheEntry>` | `notFoundCache` Not found cache.
    `protected java.util.Random` | `random` Random generator used to determine elements to free.
    `protected int` | `spareNotFoundEntries` Spare amount of not found entries.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ResourceCache()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `allocate(int space)`
    `long` | `getAccessCount()` Return the access count.
    `int` | `getCacheMaxSize()` Return the maximum size of the cache in KB.
    `int` | `getCacheSize()` Return the current cache size in KB.
    `long` | `getDesiredEntryAccessRatio()` Deprecated. - unused
    `long` | `getHitsCount()` Return the number of cache hits.
    `int` | `getMaxAllocateIterations()` Deprecated. - unused
    `int` | `getSpareNotFoundEntries()` Deprecated. - unused
    `void` | `load(CacheEntry entry)`
    `CacheEntry` | `lookup(java.lang.String name)`
    `void` | `setCacheMaxSize(int cacheMaxSize)` Set the maximum size of the cache in KB.
    `void` | `setDesiredEntryAccessRatio(long desiredEntryAccessRatio)` Deprecated. - unused
    `void` | `setMaxAllocateIterations(int maxAllocateIterations)` Deprecated. - unused
    `void` | `setSpareNotFoundEntries(int spareNotFoundEntries)` Deprecated. - unused
    `boolean` | `unload(java.lang.String name)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### random

          protected java.util.Random random

      Random generator used to determine elements to free.

    - #### cache

          protected CacheEntry[] cache

      Cache. Path -> Cache entry.

    - #### notFoundCache

          protected java.util.HashMap<java.lang.String,CacheEntry> notFoundCache

      Not found cache.

    - #### cacheMaxSize

          protected int cacheMaxSize

      Max size of resources which will have their content cached.

    - #### maxAllocateIterations

          protected int maxAllocateIterations

      Max amount of removals during a make space.

    - #### desiredEntryAccessRatio

          protected long desiredEntryAccessRatio

      Entry hit ratio at which an entry will never be removed from the cache. Compared with entry.access / hitsCount

    - #### spareNotFoundEntries

          protected int spareNotFoundEntries

      Spare amount of not found entries.

    - #### cacheSize

          protected int cacheSize

      Current cache size in KB.

    - #### accessCount

          protected long accessCount

      Number of accesses to the cache.

    - #### hitsCount

          protected long hitsCount

      Number of cache hits.

  - ### Constructor Detail

    - #### ResourceCache

          public ResourceCache()

  - ### Method Detail

    - #### getAccessCount

          public long getAccessCount()

      Return the access count. Note: Update is not synced, so the number may not be completely accurate. TODO: Currently unused. Expose via JMX?

    - #### getCacheMaxSize

          public int getCacheMaxSize()

      Return the maximum size of the cache in KB. TODO: Currently unused. Expose via JMX?

    - #### setCacheMaxSize

          public void setCacheMaxSize(int cacheMaxSize)

      Set the maximum size of the cache in KB.

    - #### getCacheSize

          public int getCacheSize()

      Return the current cache size in KB. TODO: Currently unused. Expose via JMX?

    - #### getDesiredEntryAccessRatio

          @Deprecated
          public long getDesiredEntryAccessRatio()

      Deprecated. - unused
      Return desired entry access ratio.

    - #### setDesiredEntryAccessRatio

          @Deprecated
          public void setDesiredEntryAccessRatio(long desiredEntryAccessRatio)

      Deprecated. - unused
      Set the desired entry access ratio.

    - #### getHitsCount

          public long getHitsCount()

      Return the number of cache hits. Note: Update is not synced, so the number may not be completely accurate. TODO: Currently unused. Expose via JMX?

    - #### getMaxAllocateIterations

          @Deprecated
          public int getMaxAllocateIterations()

      Deprecated. - unused
      Return the maximum amount of iterations during a space allocation.

    - #### setMaxAllocateIterations

          @Deprecated
          public void setMaxAllocateIterations(int maxAllocateIterations)

      Deprecated. - unused
      Set the maximum amount of iterations during a space allocation.

    - #### getSpareNotFoundEntries

          @Deprecated
          public int getSpareNotFoundEntries()

      Deprecated. - unused
      Return the amount of spare not found entries.

    - #### setSpareNotFoundEntries

          @Deprecated
          public void setSpareNotFoundEntries(int spareNotFoundEntries)

      Deprecated. - unused
      Set the amount of spare not found entries.

    - #### allocate

          public boolean allocate(int space)

    - #### lookup

          public CacheEntry lookup(java.lang.String name)

    - #### load

          public void load(CacheEntry entry)

    - #### unload

          public boolean unload(java.lang.String name)

Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.