The cache API enables plugins to read, write, and remove objects in the Traffic Server cache. All cache APIs are keyed by an object called an TSCacheKey; cache keys are created via TSCacheKeyCreate; keys are destroyed via TSCacheKeyDestroy. Use TSCacheKeyDigestSet to set the hash of the cache key.
Note that the cache APIs differentiate between HTTP data and plugin data. The cache APIs do not allow you to write HTTP docs in the cache; you can only write plugin-specific data (a specific type of data that differs from the HTTP type).
Example:
:::c
const unsigned char *key_name = "example key name";
TSCacheKey key;
TSCacheKeyCreate (&key);
TSCacheKeyDigestSet (key, (unsigned char *) key_name , strlen(key_name));
TSCacheKeyDestroy (key);
TSCacheRead does not really read - it is used for lookups (see the sample Protocol plugin). Possible callback events include: