Cache API
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:
TSCacheRead
does not really read - it is used for lookups (see the sample Protocol plugin). Possible callback events include:
TS_EVENT_CACHE_OPEN_READ_FAILED
- indicates the lookup was unsuccessful. Reasons for this event could be that another continuation is writing to that cache location, or the cache key doesn’t refer to a cached resource. Data payload for this event indicates the possible reason the read failed (TSCacheError
).
Use TSCacheWrite
to write to a cache (see the sample Protocol plugin). Possible callback events include:
TS_EVENT_CACHE_WRITE_READ
- indicates the lookup was successful. The data passed back along with this event is a cache vconnection that can be used to initiate a cache write.
Use to remove items from the cache. Possible callback events include:
TS_EVENT_CACHE_REMOVE
- the item was removed. There is no data payload for this event.TS_EVENT_CACHE_REMOVE_FAILED
- indicates the cache was unable to remove the item identified by the cache key.TSCacheError
data indicates why the remove failed.
Errors pertaining to the failure of various cache operations are indicated by TSCacheError
(enumeration). They are as follows:
TS_CACHE_ERROR_DOC_BUSY
- e.g, another continuation could be writing to the cache locationTS_CACHE_ERROR_NOT_READY
- the cache is not ready
In the TS_CACHE_OPEN_READ
handler:
In the TS_EVENT_VCONN_READ_READY
handler:
Do not try to get continuations or VIOs from TSVConn
objects for cache vconnections. Also note that the following APIs can only be used on transformation vconnections and must not be used on cache vconnections or net vconnections:
TSVConnWriteVIOGet
TSVConnReadVIOGet
TSVConnClosedGet
APIs such as TSVConnRead
, TSVConnWrite
, TSVConnClose
, TSVConnAbort
, and TSVConnShutdown
can be used on any kind of vconnections.