API Maker
The backend engine for the AI era
CachingEpisode 29 5:37 11 chapters November 2026
Some reads make the database do the same work again and again. One setting keeps their answers in Redis, a write drops them on its own, and a read of a table of a million rows answers in under a millisecond. See the cache key, resets from code and headers, and caching for custom APIs.
In the playlists The complete course Performance
Some reads make the database do the same work again and again. In this video, one setting keeps their answers in Redis. A write clears them by itself. And a read over a million rows answers in about a millisecond.
A cache usually means extra work. You write get and set code around every query. You design a key by hand, and it may give one caller the answer of another. Old data stays after an update, because someone forgot to clear it. And the same work is done again in every service. With API Maker, caching is one setting of a table, a database, or an API. The key is made from the caller and the request.
Every write through API Maker clears the cached answers of its table. And code or a header can reset them when you need it. In this video: caching turned on, the same read twice, the answer in Redis, a write that clears it, resets from code and headers, custom APIs, and what to know.
The support team of Calm Home looks up the events of an order by its request id. These events are in MySQL, in the database sales, in order_events. The table has a million rows. Open its Collection Settings. The default code lists what a table can set. Set enableCaching to true. Save it. Now every read API of the table is cached.
In API Testing, pick Get all of order_events, with a find for one request id. The table has no index for it. Send. It takes over a hundred milliseconds, from the database. The bar says api. Send it again. Now it takes a few milliseconds, and the bar says cache. From a terminal, the response header x-am-data-source tells where each answer came from. The first read takes over a hundred milliseconds, from the database.
The next reads take about a millisecond, from Redis. That is about a hundred times faster, and the database did nothing.
The Redis Dashboard shows what is kept. Click Expand all. You see the key of the account, then instance API, mysql, sales, and order_events. The answer is kept as it was sent, for two hours by default, and the timer counts down. A second key keeps its status and its content type. The key is the table, plus a hash of the request. This hash includes the API user, and the tokens of the person who asks.
It includes the headers that change an answer, and the query, the body, and the parameters. So two callers with different rights never share an answer, and each tenant has its own.
Now the order is delivered. Among the APIs of the table, pick Update by id. Give the id, five hundred thousand, and in the body, set event type to DELIVERED. Send. Every cached answer of order_events is cleared. Now we send the same read. It comes from the database again, and it says DELIVERED. The next one comes from the cache again.
Sometimes data changes outside API Maker, for example with an import, or a job in the database. One line of code resets a table: g dot sys dot cache dot resetCacheDB, or the system API it calls. A caller can also ask for a fresh answer, with the header x-am-cache-control set to reset_cache. From the terminal, the next read goes to the database, and it is kept again.
A custom API is cached the same way, for each body, query, and caller. resetCacheOnModificationOf names the tables whose writes clear its answers. Here, the orders report forgets its answers when order_events changes.
Good to know. A cached answer runs no hook. A hook that limits rows to the caller still holds, because the caller is part of the key. Answers longer than a limit are not kept, and every answer expires after two hours. Both are in the settings. The Redis is the external Redis that the root user sets in Deployment Settings. Every server shares it.
The setting is a file in Git, next to the table. No API has cache code in it, so nothing forgets to clear the cache. And one rule holds for every API of the table: a read is cached, and a write clears it.
To sum up. Caching is one setting. A repeated read answers in about a millisecond. The key keeps callers and tenants apart. Every write clears the cached answers of its table. And code or a header resets them when data changes outside. Next: Index Maker, for the reads that a cache cannot hold. API Maker. Build faster, spend smarter, deliver better.
Length 9:40Index Maker
Length 9:08Automatic indexes
Length 5:30Why Rust
Length 15:18Built in