Class Cache

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") @Deprecated public class Cache extends ProxyInstance
Deprecated.
Use a GHashTable instead

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.

  • Constructor Details

    • Cache

      public Cache(MemorySegment address)
      Deprecated.
      Create a Cache proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
  • Method Details

    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      Deprecated.
      The memory layout of the native struct.
      Returns:
      the memory layout
    • new_

      @Deprecated public static Cache new_(@Nullable CacheNewFunc valueNewFunc, @Nullable CacheDestroyFunc valueDestroyFunc, @Nullable CacheDupFunc keyDupFunc, @Nullable CacheDestroyFunc keyDestroyFunc, @Nullable HashFunc hashKeyFunc, @Nullable HashFunc hashValueFunc, @Nullable EqualFunc keyEqualFunc)
      Deprecated.
      Use a GHashTable instead
      Creates a new GCache.
      Parameters:
      valueNewFunc - a function to create a new object given a key. This is called by g_cache_insert() if an object with the given key does not already exist
      valueDestroyFunc - a function to destroy an object. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0)
      keyDupFunc - a function to copy a key. It is called by g_cache_insert() if the key does not already exist in the GCache
      keyDestroyFunc - a function to destroy a key. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0)
      hashKeyFunc - a function to create a hash value from a key
      hashValueFunc - a function to create a hash value from a value
      keyEqualFunc - a function to compare two keys. It should return true if the two keys are equivalent
      Returns:
      a new GCache
    • destroy

      @Deprecated public void destroy()
      Deprecated.
      Use a GHashTable instead

      Frees the memory allocated for the GCache.

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

    • insert

      @Deprecated public @Nullable MemorySegment insert(@Nullable MemorySegment key)
      Deprecated.
      Use a GHashTable instead
      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 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 GCache.
      Parameters:
      key - a key describing a GCache object
      Returns:
      a pointer to a GCache value
    • keyForeach

      @Deprecated public void keyForeach(@Nullable HFunc func)
      Deprecated.
      Use a GHashTable instead

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

      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 g_hash_table_foreach() passes key-value pairs to its callback function !

      Parameters:
      func - the function to call with each GCache key
    • remove

      @Deprecated public void remove(@Nullable MemorySegment value)
      Deprecated.
      Use a GHashTable 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().
      Parameters:
      value - the value to remove
    • valueForeach

      @Deprecated public void valueForeach(@Nullable HFunc func)
      Deprecated.
      The reason is that it passes pointers to internal data structures to func; use g_cache_key_foreach() instead
      Calls the given function for each of the values in the GCache.
      Parameters:
      func - the function to call with each GCache value