heist-0.14.1: An Haskell template system supporting both HTML5 and XML.

Safe HaskellNone
LanguageHaskell98

Heist.Splices.Cache

Description

The "cache" splice ensures that its contents are cached and only evaluated periodically. The cached contents are returned every time the splice is referenced.

Use the ttl attribute to set the amount of time between reloads. The ttl value should be a positive integer followed by a single character specifying the units. Valid units are a single letter abbreviation for one of seconds, minutes, hours, days, and weeks. If the ttl string is invalid or the ttl attribute is not specified, the cache is never refreshed unless explicitly cleared with clearCacheTagState. The compiled splice version of the cache tag does not require a cache tag state, so clearCacheTagState will not work for compiled cache tags.

Synopsis

Documentation

data CacheTagState Source

State for storing cache tag information

cacheImpl :: MonadIO n => CacheTagState -> Splice n Source

This is the splice that actually does the work. You should bind it to the same tag name as you bound the splice returned by mkCacheTag otherwise it won't work and you'll get runtime errors.

cacheImplCompiled :: MonadIO n => CacheTagState -> Splice n Source

This is the compiled splice version of cacheImpl.

mkCacheTag :: IO (Splice IO, CacheTagState) Source

Returns items necessary to set up a "cache" tag. The cache tag cannot be bound automatically with the other default Heist tags. This is because this function also returns CacheTagState, so the user will be able to clear it with the clearCacheTagState function.

This function returns a splice and a CacheTagState. The splice is of type Splice IO because it has to be bound as a load time preprocessing splice. Haskell's type system won't allow you to screw up and pass this splice as the wrong argument to initHeist.

clearCacheTagState :: CacheTagState -> IO () Source

Clears the cache tag state.