ec_datasource_cache_query — Execute a query against a datasource cache
(int) **ec_datasource_cache_query** ( | cachename, | |
| | query, | |
| | params, | |
| | closure
); | |
const char * <var class="pdparam">cachename</var>;
const char * <var class="pdparam">query</var>;
ECDict <var class="pdparam">params</var>;
ec_datasource_closure * <var class="pdparam">closure</var>;
Execute a query against a datasource cache.
When you are done, call ec_datasource_cache_delref on any results and destroy your query using ec_datasource_destroy_query.
A pointer to the datasource cache.
A pointer to the query that will be executed.
An ECDict of the query parameters. An ECDict is an ec_hash_table struct.
A pointer to the “ec_datasource_closure” struct that holds the result set and the completion routine.
The int returned is one of the following values:
ECDS_QUERY_OK is returned, you can access the result field of the “ec_datasource_cache_query” struct immediately.
In the event that the query is asynchronous—it returns
ECDS_QUERY_ASYNC—your callback function is called with the results. Prepare the query with a completion routine by setting the
job field of the ec_data_closure struct. The
job field is a struct described at ec_async_job.
A query can only be asynchronous if the function calling
ec_datasource_cache_query is capable of going asynchronous. This requires contextual knowledge about where the query is being executed.
The following code snippet shows how an ec_datasource_closure might be initialized:
ec_datasource_closure *dsc; dsc = ec_malloc_size(memtype_campaign_vsize, sizeof(*dsc)); memset(dsc, 0, sizeof(*dsc)); dsc->job.completion = ECTP_COMPLETE_CALLBACK; dsc->job.r.cb.func = completion; dsc->job.r.cb.closure = closure; dsc->job.job_class = ECTP_CLASS_IO; dsc->errmsg = erroutput;
It is legal to call this function in any thread.