<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "Tor",
  "identifier" : "/documentation/Tor/TorConfiguration/ephemeral(cacheDirectory:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Tor"
    ],
    "preciseIdentifier" : "s:3Tor0A13ConfigurationV9ephemeral14cacheDirectoryACSSSg_tFZ"
  },
  "title" : "ephemeral(cacheDirectory:)"
}
-->

# ephemeral(cacheDirectory:)

Returns a fully self-cleaning ephemeral configuration, optionally
keeping a warm cache.

```
static func ephemeral(cacheDirectory: String? = nil) -> TorConfiguration
```

## Parameters

`cacheDirectory`

Optional persistent cache path. The
cache is **not** removed on stop, so this is the single most
effective way to drop subsequent bootstrap times from ~40s to
~5–10s.

## Return Value

A `TorConfiguration` that fully disposes of its data
directory on shutdown while optionally reusing a warm cache.

## Discussion

Intended for per-session embedded Tor usage where the caller wants
zero residual state on disk after [`stop()`](/documentation/Tor/TorClient/stop()) returns.
Internally: UUID-suffixed temp directory, [`ownsDataDirectory`](/documentation/Tor/TorConfiguration/ownsDataDirectory) set
to `true`, and [`cacheDirectory`](/documentation/Tor/TorConfiguration/cacheDirectory) optionally pointed at a
caller-owned warm cache.

> Important: The cache directory is shared across sessions and
> must survive process death. Store it under a stable
> app-scoped path (not `tmp`).