---
name: "TSCacheWrite"
section: "3ts"
platform: "linux"
package: "trafficserver-dev"
version: "9.2.5+ds-0+deb12u4"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/TSCacheWrite"
---

# TSCacheWrite(3ts)

TSCacheWrite API function

## NAME

TSCacheWrite - TSCacheWrite API function

## SYNOPSIS

```
#include <ts/ts.h>
```

- ***TSAction* TSCacheWrite(*TSCont* contp, *TSCacheKey* key)**

  ## DESCRIPTION

Asks the Traffic Server cache if *contp* can start writing the object corresponding to *key* to the cache.

If the object can be written, the cache calls *contp* back with the event *TS\_EVENT\_CACHE\_OPEN\_WRITE*.  In this case, the cache also passes *contp* a cache vconnection and *contp* can then initiate a write operation on that vconnection using *TSVConnWrite*.  The object is not committed to the cache until the vconnection is closed. When all data has been transferred, the user (*contp*) must do an *TSVConnClose*.  In case of any errors, the user must do an **TSVConnAbort(contp, 0)**.

If the object cannot be written, the cache calls *contp* back with the event *TS\_EVENT\_CACHE\_OPEN\_WRITE\_FAILED*.  This can happen, for example, if there is another object with the same *key* being written to the cache.  The user (*contp*) has the option to cancel the action returned by *TSCacheWrite*.

Note that reentrant calls are possible, i.e. the cache can call back the user (*contp*) in the same call.

## COPYRIGHT

2026, dev@trafficserver.apache.org
