sdl2-compositor-1.2.0.3: image compositing with sdl2 - declarative style

Safe HaskellNone
LanguageHaskell2010

SDL.Data.Cache

Description

This module provides a simple caching implementation based on the LRU caching strategy. The cache is implemented via software transactional memory, which means that you can use the cache from different threads.

Synopsis

Documentation

class Cacheable r where Source

Something is cacheable if there is an action to release the resource (if necessary).

Methods

releaseResource :: r -> IO () Source

data Cache k a Source

newCache Source

Arguments

:: Ord k 
=> Int

the size of the cache to be created (in elements)

-> IO (Cache k a) 

Create a new cache instance.

throughCache Source

Arguments

:: (Cacheable r, Ord k) 
=> Cache k r

cache instance

-> k

cache key

-> IO r

action to generate the rsource

-> IO r 

Check if a certain element is already cached. If not execute the action the generate this element.

emptyCache :: (Cacheable r, Ord k) => Cache k r -> IO () Source

Invalidate every element in the cache and release the resources accordingly.