## GckObjectCache

GckObjectCache — An interface which holds attributes for a PKCS#11 object

## Functions

GckAttributes * | gck_object_cache_get_attributes ()
void | gck_object_cache_set_attributes ()
void | gck_object_cache_fill ()
GckAttributes * | gck_object_cache_lookup ()
void | gck_object_cache_lookup_async ()
GckAttributes * | gck_object_cache_lookup_finish ()
gboolean | gck_object_cache_update ()
void | gck_object_cache_update_async ()
gboolean | gck_object_cache_update_finish ()

## Properties

GckAttributes * | attributes | Read / Write

## Types and Values

| GckObjectCache
struct | GckObjectCacheIface

## Object Hierarchy

        GInterface
        ╰── GckObjectCache

## Prerequisites

GckObjectCache requires GckObject.

## Description

GckObjectCache is an interface implemented by derived classes of GckObject to indicate which attributes they'd like an enumerator to retrieve. These attributes are then cached on the object and can be retrieved through the “attributes” property.

## Functions

### gck_object_cache_get_attributes ()

    GckAttributes *
    gck_object_cache_get_attributes (GckObjectCache *object);

### gck_object_cache_set_attributes ()

    void
    gck_object_cache_set_attributes (GckObjectCache *object,
                                     GckAttributes *attrs);

Sets the attributes cached on this object.

If the `attrs` GckAttributes is floating, it is consumed.

#### Parameters

object | an object with an attribute cache |
attrs | the attributes to set. | [nullable]

### gck_object_cache_fill ()

    void
    gck_object_cache_fill (GckObjectCache *object,
                           GckAttributes *attrs);

Adds the attributes to the set cached on this object. If an attribute is already present in the cache it will be overridden by this value.

This will be done in a thread-safe manner.

If the `attrs` GckAttributes is floating, it is consumed.

#### Parameters

object | an object with the cache |
attrs | the attributes to cache |

### gck_object_cache_lookup ()

    GckAttributes *
    gck_object_cache_lookup (GckObject *object,
                             const gulong *attr_types,
                             gint n_attr_types,
                             GCancellable *cancellable,
                             GError **error);

Lookup attributes in the cache, or retrieve them from the object if necessary.

If `object` is a GckObjectCache then this will lookup the attributes there first if available, otherwise will read them from the object and update the cache.

If `object` is not a GckObjectCache, then the attributes will simply be read from the object.

This may block, use the asynchronous version when this is not desirable

#### Parameters

object | the object |
attr_types | the types of attributes to update. | [array length=n_attr_types]
n_attr_types | the number of attribute types |
cancellable | optional cancellation object |
error | location to place an error |

#### Returns

the attributes retrieved or `NULL` on failure.

[transfer full]

### gck_object_cache_lookup_async ()

    void
    gck_object_cache_lookup_async (GckObject *object,
                                   const gulong *attr_types,
                                   gint n_attr_types,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

Lookup attributes in the cache, or retrieve them from the object if necessary.

If `object` is a GckObjectCache then this will lookup the attributes there first if available, otherwise will read them from the object and update the cache.

If `object` is not a GckObjectCache, then the attributes will simply be read from the object.

This will return immediately and complete asynchronously

#### Parameters

object | the object |
attr_types | the types of attributes to update. | [array length=n_attr_types]
n_attr_types | the number of attribute types |
cancellable | optional cancellation object |
callback | called when the operation completes |
user_data | data to pass to the callback |

### gck_object_cache_lookup_finish ()

    GckAttributes *
    gck_object_cache_lookup_finish (GckObject *object,
                                    GAsyncResult *result,
                                    GError **error);

Complete an operation to lookup attributes in the cache or retrieve them from the object if necessary.

#### Parameters

object | the object |
result | the asynchrounous result passed to the callback |
error | location to place an error |

#### Returns

the attributes retrieved or `NULL` on failure.

[transfer full]

### gck_object_cache_update ()

    gboolean
    gck_object_cache_update (GckObjectCache *object,
                             const gulong *attr_types,
                             gint n_attr_types,
                             GCancellable *cancellable,
                             GError **error);

Update the object cache with given attributes. If an attribute already exists in the cache, it will be updated, and if it doesn't it will be added.

This may block, use the asynchronous version when this is not desirable

#### Parameters

object | the object with the cache |
attr_types | the types of attributes to update. | [array length=n_attr_types]
n_attr_types | the number of attribute types |
cancellable | optional cancellation object |
error | location to place an error |

#### Returns

whether the cache update was successful

### gck_object_cache_update_async ()

    void
    gck_object_cache_update_async (GckObjectCache *object,
                                   const gulong *attr_types,
                                   gint n_attr_types,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

Update the object cache with given attributes. If an attribute already exists in the cache, it will be updated, and if it doesn't it will be added.

This call will return immediately and complete asynchronously.

#### Parameters

object | the object with the cache |
attr_types | the types of attributes to update. | [array length=n_attr_types]
n_attr_types | the number of attribute types |
cancellable | optional cancellation object |
callback | called when the operation completes |
user_data | data to be passed to the callback |

### gck_object_cache_update_finish ()

    gboolean
    gck_object_cache_update_finish (GckObjectCache *object,
                                    GAsyncResult *result,
                                    GError **error);

Complete an asynchronous operation to update the object cache with given attributes.

#### Parameters

object | the object with the cache |
result | the asynchronous result passed to the callback |
error | location to place an error |

#### Returns

whether the cache update was successful

## Types and Values

### GckObjectCache

    typedef struct _GckObjectCache GckObjectCache;

An interface implemented on an GckObject which contains a cache of attributes.

### struct GckObjectCacheIface

    struct GckObjectCacheIface {
    	GTypeInterface interface;

    	const gulong *  default_types;
    	gint            n_default_types;

    	void         (* fill)                              (GckObjectCache *object,
    	                                                    GckAttributes *attrs);
    };

Interface for GckObjectCache. If the `default_types` field is set by a implementing class, then the a GckEnumerator which has been setup using `gck_enumerator_set_object_type()`

The implementation for `populate` should add the attributes to the cache. It must be thread safe.

#### Members

GTypeInterface `interface`; | parent interface |
const gulong *`default_types`; | attribute types that an enumerator should retrieve. | [array length=n_default_types]
gint `n_default_types`; | number of attribute types to be retrieved |
`fill` () | virtual method to add attributes to the cache |

## Property Details

### The `“attributes”` property

      “attributes”               GckAttributes *

The attributes cached on this object.

Owner: GckObjectCache

Flags: Read / Write