MySQL 8.0.39
Source Code Documentation
|
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... | |
Reference cache service.
See the reference_caching_channel service for details on how to operate this.
Manages thread caches for event producer threads.
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.
channel | the reference cache channel to operate on. | |
registry | a handle to the registry so that no time is spent taking it | |
[out] | handle | of the newly allocated cache. |
false | success |
true | failure |
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.
channel | the reference cache channel to operate on. | |
[out] | handle | of the newly allocated cache. |
false | success |
true | failure |
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.
cache | the cache to flush |
true | failure |
false | success |
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.
cache | the cache to use | |
service_index | to get references to. Must be one of the services the channel serves | |
[out] | an | array of my_h_service terminated with an empty service (0). |
true | failure |
false | success |