Class Poco::JSON::TemplateCache
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::JSON

# class TemplateCache

Library: JSON
Package: JSON
Header: Poco/JSON/TemplateCache.h

## Description

Use to cache parsed templates. Templates are stored in a map with the full path as key. When a template file has changed, the cache will remove the old template from the cache and load a new one.

## Member Summary

Member Functions: addPath, getTemplate, instance, setLogger

## Constructors

### TemplateCache

TemplateCache();

Creates an empty TemplateCache.

The cache must be created and not destroyed as long as it is used.

## Destructor

### ~TemplateCache

virtual ~TemplateCache();

Destroys the TemplateCache.

## Member Functions

### addPath

void addPath(
const Path & path
);

Add a path for resolving template paths. The order of check is FIFO.

### getTemplate

Template::Ptr getTemplate(
const Path & path
);

Returns a template from the cache. When the template file is not yet loaded or when the file has changed, the template will be (re)loaded and parsed. A shared pointer is returned, so it is safe to use this template even when the template isn't stored anymore in the cache.

### instance

static TemplateCache * instance();

Returns the only instance of this cache.

### setLogger

void setLogger(
Logger & logger
);

Sets the logger for the cache.