# LLamaKvCacheViewSafeHandle
Namespace: LLama.Native
A safe handle for a LLamaKvCacheView
```csharp
public class LLamaKvCacheViewSafeHandle : SafeLLamaHandleBase, System.IDisposable
```
Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md)
Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
## Properties
### **IsInvalid**
```csharp
public bool IsInvalid { get; }
```
#### Property Value
[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsClosed**
```csharp
public bool IsClosed { get; }
```
#### Property Value
[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors
### **LLamaKvCacheViewSafeHandle(SafeLLamaContextHandle, LLamaKvCacheView)**
Initialize a LLamaKvCacheViewSafeHandle which will call `llama_kv_cache_view_free` when disposed
```csharp
public LLamaKvCacheViewSafeHandle(SafeLLamaContextHandle ctx, LLamaKvCacheView view)
```
#### Parameters
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`view` [LLamaKvCacheView](./llama.native.llamakvcacheview.md)
## Methods
### **Allocate(SafeLLamaContextHandle, Int32)**
Allocate a new KV cache view which can be used to inspect the KV cache
```csharp
public static LLamaKvCacheViewSafeHandle Allocate(SafeLLamaContextHandle ctx, int maxSequences)
```
#### Parameters
`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
`maxSequences` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
The maximum number of sequences visible in this view per cell
#### Returns
[LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md)
### **ReleaseHandle()**
```csharp
protected bool ReleaseHandle()
```
#### Returns
[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
### **Update()**
Update this view
```csharp
public void Update()
```
### **GetView()**
Get the raw KV cache view
```csharp
public LLamaKvCacheView& GetView()
```
#### Returns
[LLamaKvCacheView&](./llama.native.llamakvcacheview&.md)