# Reset Database Cache Example

> Example demonstrating how to clear and reset database cache using API Maker.

Source: https://docs.apimaker.dev/v1/examples/sys/cache/resetCacheDB.html

`g.sys.cache.resetCacheDB` calls the [reset database cache system API](https://docs.apimaker.dev/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-db-api.html) from your code.

### Database cache reset

Reset cache of database table/collection using global object 'g'.
```ts
await g.sys.cache.resetCacheDB({
    instance: "INSTANCE_NAME", database: 'DB_NAME', collection: "COLLECTION_NAME",
});
```

### Multi-tenant
- Name the tenant after the instance to reset the cache of that tenant of a [multi-tenant](https://docs.apimaker.dev/v1/docs/features/multi-tenant.html) instance only. Without a tenant, the cache of the table is reset for its structure database and every tenant.

```ts
await g.sys.cache.resetCacheDB({ instance: "crm::acme", database: "crm", collection: "customers" }); // the tenant acme
await g.sys.cache.resetCacheDB({ instance: "crm", database: "crm", collection: "customers" });       // the structure database and every tenant
```

## Related

- [Reset database cache system API](https://docs.apimaker.dev/v1/docs/apis-all/system-apis/system-generated-reset-redis-cache-db-api.html) · [Automatic caching](https://docs.apimaker.dev/v1/docs/features/automatic-caching.html) · [The global object g](https://docs.apimaker.dev/v1/docs/pre-defined-terms/global-object-g.html)
