---
title: NewTransaction
summary: NewTransaction creates a new cache transaction for the given key.
url: https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/fn.NewTransaction/
---

**Kind:** Function  
**Module:** [core](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/)  
**Package:** compute-sdk-go v1.11.0  
**Source:** https://github.com/fastly/compute-sdk-go/blob/d6bf71b04516ed72d6018cab6fff701a865f86e5/cache/core/core.go#L537

```go
func NewTransaction(key []byte, opts LookupOptions) (*Transaction, error)
```

NewTransaction creates a new cache transaction for the given key.

Transactions must be closed by calling the [Transaction.Close](https://www.fastly.com/documentation/reference/compute/sdks/go/compute-sdk-go/cache/core/struct.Transaction/#method-Close) method
when finished.

Keys can be up to 4096 bytes in length.

**Parameters**

- `key`: `[]byte`
- `opts`: `LookupOptions`

**Returns**

`(*Transaction, error)`
