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

Safe HaskellNone
LanguageHaskell2010

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.

type FileCache = FileCacheR String Source #

A default type synonym, for String errors.

newFileCache :: IO (FileCacheR r a) Source #

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.

query Source #

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.

lazyQuery Source #

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.