Safe Haskell | Safe-Infered |
---|
Documentation
An IResource instance that must be defined for every object being cached. there are a set of implicit IResource instance trough utiliy classes (See below)
:: a | |
-> String | must be defined |
readResourceByKey :: String -> IO (Maybe a)Source
readResourceByKey
implements the database access and marshalling or of the object.
while the database access must be strict, the marshaling must be lazy if, as is often the case,
some parts of the object are not really accesed.
Moreover, if the object contains DBRefs, this avoids unnecesary cache lookups
this method is called inside atomically
blocks and thus may be interrupted without calling
Since STM transactions retry, readResourceByKey may be called twice in strange situations. So it must be idempotent, not only in the result but also in the effect in the database
writeResource :: a -> IO ()Source
the write operation in persistent storage. It must be strict.
Since STM transactions may retry, writeResource must be idempotent, not only in the result but also in the effect in the database
all the new obbects are writeen to the database on synchromization
so writeResource must not autocommit.
Commit code must be located in the postcondition. (see setConditions
)
delResource :: a -> IO ()Source
is called syncronously. It must autocommit
(Typeable a, Indexable a, Serializable a) => IResource a |
Resources data definition used by withSTMResources