public class ContentCacheImpl extends Object implements ContentCache
cacheRoot
.
The in-memory lookup table is provided by a SimpleCache implementation.
Modifier and Type | Class and Description |
---|---|
static class |
ContentCacheImpl.CacheWriter
This FileContentWriter subclass allows for the temp cache file
to be renamed to a cache file proper, e.g filename.tmp becomes
filename.bin
|
protected static class |
ContentCacheImpl.NumericFileNameComparator |
Constructor and Description |
---|
ContentCacheImpl() |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Key key)
Allows caller to perform lookup using a
Key . |
boolean |
contains(String contentUrl)
Check to see if the content - specified by URL - exists in the cache.
|
static String |
createNewCacheFilePath()
Creates a relative path for a new cache file.
|
void |
deleteFile(String url)
Deletes the cached content file for the specified URL.
|
String |
getCacheFilePath(String contentUrl)
Get the path of a cache file for the given content URL - will return null if there is no entry
in the cache for the specified URL.
|
File |
getCacheRoot()
Returns the directory where cache files will be written (cacheRoot).
|
String |
getContentUrl(File file)
Get a content URL from the cache - keyed by File.
|
org.alfresco.service.cmr.repository.ContentReader |
getReader(String contentUrl)
Retrieve a ContentReader for the cached content specified by URL.
|
org.alfresco.service.cmr.repository.ContentWriter |
getWriter(String url)
Retrieve a ContentWriter to write content to a cache file.
|
void |
processFiles(FileHandler handler)
Ask the ContentCacheImpl to visit all the content files in the cache.
|
boolean |
put(String contentUrl,
org.alfresco.service.cmr.repository.ContentReader source)
Put an item into cache - this will populate both a disk file (with content) and
the in-memory lookup table (with the URL and cache file location).
|
void |
putIntoLookup(Key key,
String value)
Put an item in the lookup table.
|
void |
remove(String contentUrl)
Remove a cached item from the in-memory lookup table.
|
void |
removeAll()
Remove all items from the lookup table.
|
void |
setCacheRoot(File cacheRoot)
Specify the directory where cache files will be written.
|
void |
setMemoryStore(org.alfresco.repo.cache.SimpleCache<Key,String> memoryStore)
Configure ContentCache with a memory store.
|
public boolean contains(String contentUrl)
ContentCache
Note that just because the in-memory cache has a record of the content item having been placed into the cache, it does not mean that the disk item is guaranteed to be there. The temp file clean-up process, for example, may have removed it.
contains
in interface ContentCache
contentUrl
- Stringpublic boolean contains(Key key)
Key
.key
- Keypublic void putIntoLookup(Key key, String value)
key
- Keyvalue
- Stringpublic String getCacheFilePath(String contentUrl)
contentUrl
- Stringpublic String getContentUrl(File file)
file
- Filepublic org.alfresco.service.cmr.repository.ContentReader getReader(String contentUrl)
ContentCache
getReader
in interface ContentCache
contentUrl
- Stringpublic boolean put(String contentUrl, org.alfresco.service.cmr.repository.ContentReader source)
ContentCache
put
in interface ContentCache
contentUrl
- Stringsource
- ContentReaderpublic void remove(String contentUrl)
ContentCache
ContentCache.deleteFile(String)
.remove
in interface ContentCache
contentUrl
- Stringpublic void removeAll()
public void deleteFile(String url)
ContentCache
ContentCache.remove(String)
after calling this method.deleteFile
in interface ContentCache
url
- Stringpublic org.alfresco.service.cmr.repository.ContentWriter getWriter(String url)
ContentCache
getWriter
in interface ContentCache
url
- urlpublic static String createNewCacheFilePath()
e.g. 2011/12/3/13/55/27d56416-bf9f-4d89-8f9e-e0a52de0a59e.bin
public void setMemoryStore(org.alfresco.repo.cache.SimpleCache<Key,String> memoryStore)
memoryStore
- the memoryStore to setpublic void setCacheRoot(File cacheRoot)
cacheRoot
- Filepublic File getCacheRoot()
getCacheRoot
in interface ContentCache
public void processFiles(FileHandler handler)
handler
- FileHandlerCopyright © 2005–2017 Alfresco Software. All rights reserved.