vcache-0.1: large, persistent, memcached values and structure sharing for Haskell

Safe HaskellNone
LanguageHaskell2010

Database.VCache.Cache

Description

Limited cache control.

Synopsis

Documentation

setVRefsCacheLimit :: VSpace -> Int -> IO () Source

VCache uses simple heuristics to decide which VRef contents to hold in memory. One heuristic is a target cache size. Developers may tune this to influence how many VRefs are kept in memory.

The value is specified in bytes, and the default is ten megabytes.

VCache size estimates are imprecise, converging on approximate size, albeit not accounting for memory amplification (e.g. from a compact UTF-8 string to Haskell's representation for [Char]). The limit given here is soft, influencing how aggressively content is removed from cache - i.e. there is no hard limit on content held by the cache. Estimated cache size is observable via vcacheStats.

If developers need precise control over caching, they should use normal means to reason about GC of values in Haskell (i.e. VRef is cleared from cache upon GC). Or use vref' and deref' to avoid caching and use VCache as a simple serialization layer.

clearVRefsCache :: VSpace -> IO () Source

clearVRefsCache will iterate over cached VRefs in Haskell memory at the time of the call, clearing the cache for each of them. This operation isn't recommended for common use. It is rather hostile to independent libraries working with VCache. But this function may find some use for benchmarks or staged applications.

clearVRefCache :: VRef a -> IO () Source

Immediately clear the cache associated with a VRef, allowing any contained data to be GC'd. Normally, VRef cached values are cleared either by a background thread or when the VRef itself is garbage collected from Haskell memory. But sometimes the programmer knows best.