HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulelrucache-1.2.0.1Haskell98

Data.Cache.LRU.IO

This module contains a mutable wrapping of an LRU in the IO monad, providing atomic access in a concurrent environment. All calls preserve the same semantics as those in Data.Cache.LRU, but perform updates in place. All functions use a single atomic update of the backing structure.

The interface this module provides is opaque. If further control is desired, the Data.Cache.LRU.IO.Internal module can be used in combination with Data.Cache.LRU.Internal.

(This implementation uses an MVar for coarse locking. It's unclear if anything else would give better performance, given that many calls alter the head of the access list.)

Synopsis
valuedelete :: Ord key => key -> AtomicLRU key val -> IO (Maybe val)

Remove an item from an AtomicLRU. Returns the value for the removed key, if it was present

valuepop :: Ord key => AtomicLRU key val -> IO (Maybe (key, val))

Remove the least-recently accessed item from an AtomicLRU. Returns the (key, val) pair removed, if one was present.

valuemodifyAtomicLRU'
  1. :: LRU key val -> IO (LRU key val)
  2. -> AtomicLRU key val
  3. -> IO ()

Given a function that takes an LRU and returns an IO action producting one of the same type, use it to modify the contents of this AtomicLRU.