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

Remove redis key

Deletes keys stored with set redis key. A key which is not there is skipped without an error, so the call can run again.

Method POST
URL /api/system-api/admin/remove-redis-key : admin is the user path of your account
Body { keys }
Answer data : true
From code g.sys.cache.removeKey

The call

Body : one key
{ "keys": [ "session:user123" ] }
Body : several keys
{ "keys": [ "session:user123", "captcha:abc" ] }
Answer
{ "success": true, "statusCode": 200, "data": true }
  • No wildcards, on purpose : a pattern could delete the cache of the APIs. Name the keys.

From code

await g.sys.cache.removeKey('session:user123');
await g.sys.cache.removeKey([ 'session:user123', 'captcha:abc' ]);
await g.sys.cache.remove_key('session:user123')
await g.sys.cache.remove_keys(['session:user123', 'captcha:abc'])
$g->sys->cache->removeKey('session:user123');
$g->sys->cache->removeKeys(['session:user123', 'captcha:abc']);
await g.Sys.Cache.RemoveKey("session:user123");
await g.Sys.Cache.RemoveKeys(["session:user123", "captcha:abc"]);
if _, err := g.Sys.Cache.RemoveKey("session:user123"); err != nil {
    return nil, err
}
if _, err := g.Sys.Cache.RemoveKeys([]string{"session:user123", "captcha:abc"}); err != nil {
    return nil, err
}
g.sys.cache.remove_key("session:user123")?;
g.sys.cache.remove_keys(&["session:user123", "captcha:abc"])?;
g.sys.cache.removeKey("session:user123");
g.sys.cache.removeKeys(List.of("session:user123", "captcha:abc"));
g.sys.cache.removeKey("session:user123")
g.sys.cache.removeKeys(listOf("session:user123", "captcha:abc"))
  • To clear the cached answers of an API rather than your own keys, use the reset cache APIs : database, custom, system.

Access and settings

  • Over HTTP, a system API answers once its settings give it apiAccessType: TOKEN_ACCESS (the token of an API user whose group grants this system API, in x-am-authorization) or IS_PUBLIC. Without settings it is NO_ACCESS : your code calls it through g.sys, the admin panel tests it, and an HTTP call is refused.
  • The settings can also cache the answer or require person tokens (authProviders) ; pre and post hooks run around it like around any API.
  • The request headers apply : x-am-response-case, x-am-content-type-response, x-am-internationalization, x-am-tenant-username…

Errors

Code When
400 The body is wrong : the message names the missing or invalid key.
401 No valid API user token, or the API is NO_ACCESS : You are not authorized to access this API.
403 No group grants this system API.