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, 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