Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GI.GLib.Structs.Cache
Description
A GCache
allows sharing of complex data structures, in order to
save system resources.
GCache
uses keys and values. A GCache
key describes the properties
of a particular resource. A GCache
value is the actual resource.
GCache
has been marked as deprecated, since this API is rarely
used and not very actively maintained.
Synopsis
- newtype Cache = Cache (ManagedPtr Cache)
- cacheDestroy :: (HasCallStack, MonadIO m) => Cache -> m ()
- cacheInsert :: (HasCallStack, MonadIO m) => Cache -> Ptr () -> m (Ptr ())
- cacheKeyForeach :: (HasCallStack, MonadIO m) => Cache -> HFunc -> m ()
- cacheRemove :: (HasCallStack, MonadIO m) => Cache -> Ptr () -> m ()
- cacheValueForeach :: (HasCallStack, MonadIO m) => Cache -> HFunc -> m ()
Exported types
Memory-managed wrapper type.
Instances
Eq Cache Source # | |
BoxedPtr Cache Source # | |
Defined in GI.GLib.Structs.Cache | |
ManagedPtrNewtype Cache Source # | |
Defined in GI.GLib.Structs.Cache Methods toManagedPtr :: Cache -> ManagedPtr Cache |
Methods
Click to display all available methods, including inherited ones
destroy
Arguments
:: (HasCallStack, MonadIO m) | |
=> Cache |
|
-> m () |
insert
Arguments
:: (HasCallStack, MonadIO m) | |
=> Cache |
|
-> Ptr () |
|
-> m (Ptr ()) | Returns: a pointer to a |
Deprecated: (Since version 2.32)Use a HashTable
instead
Gets the value corresponding to the given key, creating it if
necessary. It first checks if the value already exists in the
Cache
, by using the keyEqualFunc
function passed to
g_cache_new()
. If it does already exist it is returned, and its
reference count is increased by one. If the value does not currently
exist, if is created by calling the valueNewFunc
. The key is
duplicated by calling keyDupFunc
and the duplicated key and value
are inserted into the Cache
.
keyForeach
Arguments
:: (HasCallStack, MonadIO m) | |
=> Cache |
|
-> HFunc |
|
-> m () |
Deprecated: (Since version 2.32)Use a HashTable
instead
Calls the given function for each of the keys in the Cache
.
NOTE func
is passed three parameters, the value and key of a cache
entry and the userData
. The order of value and key is different
from the order in which hashTableForeach
passes key-value
pairs to its callback function !
remove
Arguments
:: (HasCallStack, MonadIO m) | |
=> Cache |
|
-> Ptr () |
|
-> m () |
Deprecated: (Since version 2.32)Use a HashTable
instead
Decreases the reference count of the given value. If it drops to 0
then the value and its corresponding key are destroyed, using the
valueDestroyFunc
and keyDestroyFunc
passed to g_cache_new()
.
valueForeach
Arguments
:: (HasCallStack, MonadIO m) | |
=> Cache |
|
-> HFunc |
|
-> m () |
Deprecated: (Since version 2.10)The reason is that it passes pointers to internal data structures to func
; use cacheKeyForeach
instead
Calls the given function for each of the values in the Cache
.