add_atomic


Description:

[ Version ( since = "3.62" ) ]
public IOStream add_atomic (string path, string key) throws Error

Open a temporary file for writing a new cache item identified by path and key.

The temporary file lives in the same directory as the final target so that commit_atomic can rename it into place atomically (same-filesystem rename).

Any concurrent call to @get for the same path/key will block until the caller either commits or discards the stream.

On success, pass the returned stream to commit_atomic or discard_atomic; the stream is consumed (transfer full) by both functions. Do not call unref on it directly.

Parameters:

this

A DataCache

path

Relative path of item to add.

key

Key of item to add.

Returns:

a IOStream for writing, or null on error