CamlTemplate API Documentation : CamlTemplate.Cache

# Module CamlTemplate.Cache

    module Cache: sig .. end

Caches templates.

# Customising How Source Code is Loaded

`type ``source_check_result =`

`|` | `TemplateUnchanged` | `(*` | `Indicates that the source code of the checked template has not changed since it was loaded.` | `*)`
`|` | `TemplateChanged` | `(*` | `Indicates that the source code of the checked template has changed since it was loaded.` | `*)`
`|` | `TemplateDeleted` | `(*` | `Indicates that the source code of the checked template was deleted since it was loaded.` | `*)`

The type returned by a template source loader when it checks whether a template's source code has changed.

    class type source_loader = object .. end

An implementation of this class type can be used by a template cache to load template source code.

    val as_source_loader : #source_loader -> source_loader

Upcasting function for `CamlTemplate.Cache.source_loader`.

    val make_file_loader : template_dir:string -> source_loader

Returns a `CamlTemplate.Cache.source_loader` that loads template source code from files in a directory. The name of each template is used as the filename.
`template_dir` : the directory in which the template source files are located.

# Using Template Caches

    type t

The type of template caches.

    val create : ?loader:source_loader ->
           ?check_interval:float -> unit -> t

Creates a template cache.
`loader` : the `source_loader` that will be used to load template source code for the cache. If omitted, the cache uses a `source_loader` that loads template source code from the current working directory.
`check_interval` : the interval at which the template cache should be refreshed. The default is 5 minutes. If the interval is zero, the cache will be refreshed every time `CamlTemplate.Cache.get_template` is called. If the interval is negative, it will never be refreshed.

    val get_template : cache:t -> template_name:string -> CamlTemplate.template

Given a cache and the name of a template, returns the template from the cache. If the template is not in the cache, it is loaded and cached.

If the cache is due to be refreshed, this method refreshes the cache (i.e. reloads any templates that have been modified since they were last loaded, and removes any deleted templates from the cache) before looking for the requested template.
Raises `CamlTemplate.Syntax_error` if a template cannot be parsed.