gi-glib-2.0.30: GLib bindings

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

Contents

- Exported types
- Methods
  - destroy
  - insert
  - keyForeach
  - remove
  - valueForeach

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

newtype Cache Source #

Memory-managed wrapper type.

Constructors

Cache (ManagedPtr Cache) |

#### Instances

Instances details

Eq Cache Source # |
Instance details Defined in GI.GLib.Structs.Cache Methods (==) :: Cache -> Cache -> Bool Source # (/=) :: Cache -> Cache -> Bool Source #
BoxedPtr Cache Source # |
Instance details Defined in GI.GLib.Structs.Cache Methods boxedPtrCopy :: Cache -> IO Cache Source # boxedPtrFree :: Cache -> IO () Source #
ManagedPtrNewtype Cache Source # |
Instance details Defined in GI.GLib.Structs.Cache Methods toManagedPtr :: Cache -> ManagedPtr Cache Source #

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

destroy, insert, keyForeach, remove, valueForeach.

#### Getters

None.

#### Setters

None.

## destroy

cacheDestroy Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Cache | `cache`: a `Cache`
-> m () |

Deprecated: (Since version 2.32)Use a `HashTable` instead

Frees the memory allocated for the `Cache`.

Note that it does not destroy the keys and values which were contained in the `Cache`.

## insert

cacheInsert Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Cache | `cache`: a `Cache`
-> Ptr () | `key`: a key describing a `Cache` object
-> m (Ptr ()) | Returns: a pointer to a `Cache` value

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

cacheKeyForeach Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Cache | `cache`: a `Cache`
-> HFunc | `func`: the function to call with each `Cache` key
-> 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

cacheRemove Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Cache | `cache`: a `Cache`
-> Ptr () | `value`: the value to remove
-> 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

cacheValueForeach Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> Cache | `cache`: a `Cache`
-> HFunc | `func`: the function to call with each `Cache` value
-> 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`.