GLib.Cache
Description: Reference for GLib.Cache

### Struct

# GLibCache

deprecated: 2.32 since: 2.0

#### Description

    struct GCache {
      /* No available fields */
    }

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.

Available since: 2.0

Deprecated since: 2.32

Use a `GHashTable` instead.

#### Functions

###### g_cache_new

Creates a new `GCache`.

deprecated: 2.32 since: 2.0

#### Instance methods

###### g_cache_destroy

Frees the memory allocated for the `GCache`.

deprecated: 2.32 since: 2.0

###### g_cache_insert

Gets the value corresponding to the given key, creating it if necessary. It first checks if the value already exists in the `GCache`, by using the `key_equal_func` 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 `value_new_func`. The key is duplicated by calling `key_dup_func` and the duplicated key and value are inserted into the `GCache`.

deprecated: 2.32 since: 2.0

###### g_cache_key_foreach

Calls the given function for each of the keys in the `GCache`.

deprecated: 2.32 since: 2.0

###### g_cache_remove

Decreases the reference count of the given value. If it drops to 0 then the value and its corresponding key are destroyed, using the `value_destroy_func` and `key_destroy_func` passed to g_cache_new().

deprecated: 2.32 since: 2.0

###### g_cache_value_foreach

Calls the given function for each of the values in the `GCache`.

deprecated: 2.10 since: 2.0