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

Data.FileCache.Internal

Description

Internal module ... use at your own risks!

Synopsis

# Documentation

data FileCacheR r a Source #

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

Constructors

 FileCache Fields_cache :: TVar (Map FilePath (Either r a)) _watchedDirs :: TVar (Map FilePath (Set FilePath, StopListening)) _manager :: WatchManager _channel :: EventChannel _tid :: TVar (Maybe ThreadId)

A default type synonym, for String errors.

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.

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.

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

Gets a copy of the cache.