Class CachingContentStore

java.lang.Object
org.alfresco.repo.content.caching.CachingContentStore
All Implemented Interfaces:
ContentStore, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationEventPublisherAware

public class CachingContentStore extends Object implements ContentStore, org.springframework.context.ApplicationEventPublisherAware, org.springframework.beans.factory.BeanNameAware
Implementation of ContentStore that wraps any other ContentStore (the backing store) transparently providing caching of content in that backing store.

CachingContentStore should only be used to wrap content stores that are significantly slower that FileContentStore - otherwise performance may actually degrade from its use.

It is important that cacheOnInbound is set to true for exceptionally slow backing stores.

This store handles the FileContentStore.SPOOF_PROTOCOL and can be used to wrap stores that do not handle the protocol out of the box e.g. the S3 connector's store.

Author:
Matt Ward
  • Constructor Details

    • CachingContentStore

      public CachingContentStore()
    • CachingContentStore

      public CachingContentStore(ContentStore backingStore, ContentCache cache, boolean cacheOnInbound)
  • Method Details

    • init

      public void init()
      Initialisation method, should be called once the CachingContentStore has been constructed.
    • isContentUrlSupported

      public boolean isContentUrlSupported(String contentUrl)
      Specified by:
      isContentUrlSupported in interface ContentStore
    • isWriteSupported

      public boolean isWriteSupported()
      Specified by:
      isWriteSupported in interface ContentStore
    • getSpaceFree

      public long getSpaceFree()
      Specified by:
      getSpaceFree in interface ContentStore
    • getSpaceTotal

      public long getSpaceTotal()
      Specified by:
      getSpaceTotal in interface ContentStore
    • getRootLocation

      public String getRootLocation()
      Specified by:
      getRootLocation in interface ContentStore
    • exists

      public boolean exists(String contentUrl)

      For spoofed URLs, the URL always exists.

      Specified by:
      exists in interface ContentStore
    • getReader

      public ContentReader getReader(String contentUrl)

      This store handles the FileContentStore.SPOOF_PROTOCOL so that underlying stores do not need to implement anything related to spoofing.

      Specified by:
      getReader in interface ContentStore
    • getWriter

      public ContentWriter getWriter(ContentContext context)
      Specified by:
      getWriter in interface ContentStore
    • delete

      public boolean delete(String contentUrl)
      Specified by:
      delete in interface ContentStore
    • readWriteLock

      public ReentrantReadWriteLock readWriteLock(String url)
      Get a ReentrantReadWriteLock for a given URL. The lock is from a pool rather than per URL, so some contention is expected.
      Parameters:
      url - String
      Returns:
      ReentrantReadWriteLock
    • setBackingStore

      public void setBackingStore(ContentStore backingStore)
    • getBackingStoreType

      public String getBackingStoreType()
    • getBackingStoreDescription

      public String getBackingStoreDescription()
    • setCache

      public void setCache(ContentCache cache)
    • getCache

      public ContentCache getCache()
    • setCacheOnInbound

      public void setCacheOnInbound(boolean cacheOnInbound)
    • isCacheOnInbound

      public boolean isCacheOnInbound()
    • getMaxCacheTries

      public int getMaxCacheTries()
    • setMaxCacheTries

      public void setMaxCacheTries(int maxCacheTries)
    • setQuota

      public void setQuota(QuotaManagerStrategy quota)
      Sets the QuotaManagerStrategy that will be used.
      Parameters:
      quota - QuotaManagerStrategy
    • getQuota

      public QuotaManagerStrategy getQuota()
    • setApplicationEventPublisher

      public void setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher applicationEventPublisher)
      Specified by:
      setApplicationEventPublisher in interface org.springframework.context.ApplicationEventPublisherAware
    • setBeanName

      public void setBeanName(String name)
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • getBeanName

      public String getBeanName()
    • isDirectAccessSupported

      public boolean isDirectAccessSupported()
      Specified by:
      isDirectAccessSupported in interface ContentStore
    • getDirectAccessUrl

      public DirectAccessUrl getDirectAccessUrl(String contentUrl, Date expiresAt)
      Specified by:
      getDirectAccessUrl in interface ContentStore