Class DefaultCockpitResourceCache

  • All Implemented Interfaces:
    CockpitResourceCache, Resettable

    public class DefaultCockpitResourceCache
    extends java.lang.Object
    implements CockpitResourceCache
    Default CockpitResourceCache implementation. Uses a ConcurrentHashMap for caching and ReentrantReadWriteLock for handling concurrent access.
    • Field Detail

      • COCKPITNG_RESOURCELOADER_RESOURCECACHE_MAXENTRYSIZE

        public static final java.lang.String COCKPITNG_RESOURCELOADER_RESOURCECACHE_MAXENTRYSIZE
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultCockpitResourceCache

        public DefaultCockpitResourceCache()
    • Method Detail

      • getResourceAsBytes

        public byte[] getResourceAsBytes​(java.lang.String uuid)
        Description copied from interface: CockpitResourceCache
        Gets the resource for the given key, if present in cache.
        Specified by:
        getResourceAsBytes in interface CockpitResourceCache
        Returns:
        The cached byte array, or null, if not in cache.
      • addResourceToCache

        public byte[] addResourceToCache​(java.lang.String uuid,
                                         byte[] resource)
        Description copied from interface: CockpitResourceCache
        Adds a chunk of bytes to the cache.
        Specified by:
        addResourceToCache in interface CockpitResourceCache
        Parameters:
        uuid - The unique key for the resource, usually an uri.
        resource - The resource to add as byte array.
        Returns:
        The passed resource, for convenience reasons.
      • getMaxEntrySize

        public long getMaxEntrySize()
      • initMaxEntrySize

        protected long initMaxEntrySize()
      • setMaxEntrySize

        public void setMaxEntrySize​(long maxEntrySize)
      • setCockpitProperties

        public void setCockpitProperties​(CockpitProperties cockpitProperties)