filecache-0.4.1: A cache system associating values to files.

Data.FileCache

Description

This module let you create caches where keys are file names, and values are automatically expired when the file is modified for any reason.

This is usually done in the following fashion :

cache <- newFileCache
o <- query cache "/path/to/file" computation

The computation will be used to populate the cache if this call results in a miss. The result is forced to WHNM.

Synopsis

Documentation

A default type synonym, for String errors.

data FileCacheR r a Source #

The main FileCache type, for queries returning 'Either r a'. The r type must be an instance of Error.

Generates a new file cache. The opaque type is for use with other functions.

killFileCache :: FileCacheR r a -> IO () Source #

Destroys the thread running the FileCache. Pretty dangerous stuff.

invalidate :: FilePath -> FileCacheR e a -> IO () Source #

Manually invalidates an entry.

Arguments

 :: IsString e => FileCacheR e a -> FilePath Path of the file entry -> IO (Either e a) The computation that will be used to populate the cache -> IO (Either e a)

Queries the cache, populating it if necessary, returning a strict Either (from Data.Either.Strict).

Queries that fail with an IOExeception will not create a cache entry.

getCache :: FileCacheR e a -> IO (Map FilePath (Either e a)) Source #

Gets a copy of the cache.

Arguments

 :: IsString r => FileCacheR r a -> FilePath Path of the file entry -> IO (Either r a) The computation that will be used to populate the cache -> IO (Either r a)

Just like query, but with the standard Either type. Note that it is just there for easy interoperability with the more comme Either type, as the result is still forced.