GLib.Cache¶
Fields¶
None
Methods¶
|
|
|
|
|
|
|
|
|
Details¶
- class GLib.Cache¶
A
GCache
allows sharing of complex data structures, in order to save system resources.GCache
uses keys and values. AGCache
key describes the properties of a particular resource. AGCache
value is the actual resource.GCache
has been marked as deprecated, since this API is rarely used and not very actively maintained.Deprecated since version 2.32: Use a
GLib.HashTable
instead- destroy()[source]¶
Frees the memory allocated for the
GLib.Cache
.Note that it does not destroy the keys and values which were contained in the
GLib.Cache
.Deprecated since version 2.32: Use a
GLib.HashTable
instead
- insert(key)[source]¶
- Parameters:
key (
object
orNone
) – a key describing aGLib.Cache
object- Returns:
a pointer to a
GLib.Cache
value- Return type:
Gets the value corresponding to the given key, creating it if necessary. It first checks if the value already exists in the
GLib.Cache
, 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 theGLib.Cache
.Deprecated since version 2.32: Use a
GLib.HashTable
instead
- key_foreach(func, *user_data)[source]¶
- Parameters:
func (
GLib.HFunc
) – the function to call with eachGLib.Cache
keyuser_data (
object
orNone
) – user data to pass to the function
Calls the given function for each of the keys in the
GLib.Cache
.NOTE func is passed three parameters, the value and key of a cache entry and the user_data. The order of value and key is different from the order in which
GLib.HashTable.foreach
() passes key-value pairs to its callback function !Deprecated since version 2.32: Use a
GLib.HashTable
instead
- remove(value)[source]¶
-
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 since version 2.32: Use a
GLib.HashTable
instead
- value_foreach(func, *user_data)[source]¶
- Parameters:
func (
GLib.HFunc
) – the function to call with eachGLib.Cache
valueuser_data (
object
orNone
) – user data to pass to the function
Calls the given function for each of the values in the
GLib.Cache
.Deprecated since version 2.10: The reason is that it passes pointers to internal data structures to func; use
GLib.Cache.key_foreach
() instead