MySQL 9.1.0
Source Code Documentation
s_mysql_reference_caching_cache Struct Reference

Reference cache service. More...

#include <reference_caching.h>

Public Attributes

mysql_service_status_t(* create )(reference_caching_channel channel, const mysql_service_registry_t *registry, reference_caching_cache *out_cache)
 Create a reference cache. More...
 
mysql_service_status_t(* destroy )(reference_caching_cache cache)
 Destroy a reference cache. More...
 
mysql_service_status_t(* get )(reference_caching_cache cache, unsigned service_index, const my_h_service **refs)
 Gets a set of service references for an event producer to call. More...
 
mysql_service_status_t(* flush )(reference_caching_cache cache)
 Flush a reference cache. More...
 

Detailed Description

Reference cache service.

See the reference_caching_channel service for details on how to operate this.

Manages thread caches for event producer threads.

Member Data Documentation

◆ create

mysql_service_status_t(* s_mysql_reference_caching_cache::create) (reference_caching_channel channel, const mysql_service_registry_t *registry, reference_caching_cache *out_cache)

Create a reference cache.

Needs to be called before the first get() or flush() is called. Each call to create must be paired with a call to destroy() or there will be leaks.

Parameters
channelthe reference cache channel to operate on.
registrya handle to the registry so that no time is spent taking it
[out]handleof the newly allocated cache.
Return values
falsesuccess
truefailure

◆ destroy

mysql_service_status_t(* s_mysql_reference_caching_cache::destroy) (reference_caching_cache cache)

Destroy a reference cache.

Needs to be called to dispose of each cache allocated by create(). Needs to be called after all possible calls to get() and flush(). Once called the cache handle is invalid and should not be used anymore.

Parameters
channelthe reference cache channel to operate on.
[out]handleof the newly allocated cache.
Return values
falsesuccess
truefailure

◆ flush

mysql_service_status_t(* s_mysql_reference_caching_cache::flush) (reference_caching_cache cache)

Flush a reference cache.

This causes the reference cache supplied to be flushed. When in this state the next call to get() will be a guaranteed cache miss and will fill in the cache.

Parameters
cachethe cache to flush
Return values
truefailure
falsesuccess

◆ get

mysql_service_status_t(* s_mysql_reference_caching_cache::get) (reference_caching_cache cache, unsigned service_index, const my_h_service **refs)

Gets a set of service references for an event producer to call.

This is the main event producer function that will be called when the event producer needs to produce an event.

The cache must be a valid one. And the channel too.

If the cache is empty or invalidated (either via the channel or via a call to flush) it will try to fill it by consulting the registry and acquiring references to all implementations of the service the channel is created for. Once that is done the cache will be marked as full. This a cache "miss": a relatively expensive operation and care must be taken so it doesn't happen very often.

If the cache is full (not flushed) this call will return all references stored into the cache (might be zero too). This is a very fast operation since the cache is single-thread-use and thus no synchronization will be done (except for checking the channel's state of course). This is a cache "hit" and should be the normal operation of the cache.

Parameters
cachethe cache to use
service_indexto get references to. Must be one of the services the channel serves
[out]anarray of my_h_service terminated with an empty service (0).
Return values
truefailure
falsesuccess

The documentation for this struct was generated from the following file: