Skip to content
This page View Markdown Open in ChatGPT Open in Claude

Reset custom API cache

Drops the cached answers of a custom API with enableCaching. resetCacheOnModificationOf in its settings does it on its own when a table it names is written ; this API is for the other cases.

Method POST
URL /api/system-api/admin/reset-redis-cache-custom-apis : admin is the user path of your account
Body { name, tenantUsername? } or an array of them
Answer data : the number of cache entries removed
From code g.sys.cache.resetCacheCustomApis

The call

Body : one custom API
{ "name": "customers-report" }
Body : several
[ { "name": "customers-report" }, { "name": "top-products" } ]
Body : one tenant
{ "name": "customers-report", "tenantUsername": "acme" }
Answer
{ "success": true, "statusCode": 200, "data": 1 }
  • name is the name of the custom API (its settings), not its path. An unknown name gives -1 and a 404 in errors.
  • Without tenantUsername, the cached answers of every tenant and of the calls without a tenant are reset.

From code

await g.sys.cache.resetCacheCustomApis('customers-report');
await g.sys.cache.resetCacheCustomApis({ name: 'customers-report', tenantUsername: 'acme' });
await g.sys.cache.reset_cache_custom_apis('customers-report')
await g.sys.cache.reset_cache_custom_apis_of_tenant('customers-report', 'acme')
$g->sys->cache->resetCacheCustomApis('customers-report');
$g->sys->cache->resetCacheCustomApisOfTenant('customers-report', 'acme');
await g.Sys.Cache.ResetCacheCustomApis("customers-report");
await g.Sys.Cache.ResetCacheCustomApisOfTenant("customers-report", "acme");
if _, err := g.Sys.Cache.ResetCacheCustomApis("customers-report"); err != nil {
    return nil, err
}
if _, err := g.Sys.Cache.ResetCacheCustomApisOfTenant("customers-report", "acme"); err != nil {
    return nil, err
}
g.sys.cache.reset_cache_custom_apis("customers-report")?;
g.sys.cache.reset_cache_custom_apis_of_tenant("customers-report", "acme")?;
g.sys.cache.resetCacheCustomApis("customers-report");
g.sys.cache.resetCacheCustomApisOfTenant("customers-report", "acme");
g.sys.cache.resetCacheCustomApis("customers-report")
g.sys.cache.resetCacheCustomApisOfTenant("customers-report", "acme")

Access, headers and errors

  • Over HTTP, a system API answers only once its settings open it : TOKEN_ACCESS (the token of an API user whose group grants this system API) or IS_PUBLIC. Without settings it is NO_ACCESS : only your code (g.sys) and the admin panel reach it.
  • The settings can also keep the answer in the cache, or ask for the token of a person (authProviders). Pre and post hooks run around it, as around any API.
  • It takes the request headers and answers the envelope. 401 : no valid token, or the API is NO_ACCESS. 403 : no group grants it. 400 : the body is wrong, and the message names the key.

Related : All APIs · System API settings · System APIs from code