Package org.apache.sling.fsprovider.internal.parser

# Class ContentFileCache

java.lang.Object
org.apache.sling.fsprovider.internal.parser.ContentFileCache

public final class ContentFileCache extends Object
Cache for parsed content from content files (e.g. JSON, JCR XML).

## Constructor Summary

Constructors
Constructor
Description
`ContentFileCache(int maxSize)`

## Method Summary

Modifier and Type
Method
Description
`void`
`clear()`
Clear whole cache
`ContentElement`
`get(String path, File file)`
Get content.
`ContentElement`
`get(String path, File file, ContentType contentType)`
Get content.
`void`
`remove(String path)`
Remove content from cache.
`int`
`size()`

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

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

## Constructor Details

### ContentFileCache

public ContentFileCache(int maxSize)

Parameters:
  `maxSize` - Cache size. 0 = caching disabled.

## Method Details

### get

public ContentElement get(String path, File file)
Get content.

Parameters:
  `path` - Path (used as cache key).
  `file` - File
Returns:
  Content or null

### get

public ContentElement get(String path, File file, ContentType contentType)
Get content.

Parameters:
  `path` - Path (used as cache key).
  `file` - File
  `contentType` - Content type - if null type is auto-detected
Returns:
  Content or null

### remove

public void remove(String path)
Remove content from cache.

Parameters:
  `path` - Path (used as cache key)

### clear

public void clear()
Clear whole cache

### size

public int size()

Returns:
  Current cache size