# IGrainDirectoryCache Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/)

## AddOrUpdate(GrainAddress, int) {#addorupdate-orleans-runtime-grainaddress-int-89e5235c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/methods/addorupdate-orleans-runtime-grainaddress-int-89e5235c/)

```csharp
public abstract void AddOrUpdate(GrainAddress value, int version)
```

Adds a new entry with the given version into the cache: key (grain) --&gt; value The new entry will override any existing entry under the given key, regardless of the stored version

### Parameters

- `value` (`GrainAddress`): value to add
- `version` (`int`): version for the value

## Clear {#clear-6ed0b4d9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/methods/clear-6ed0b4d9/)

```csharp
public abstract void Clear()
```

Clear the cache, deleting all entries.

## LookUp(GrainId, GrainAddress, int) {#lookup-orleans-runtime-grainid-out-orleans-runtime-grainaddress-out-int-790505ca}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/methods/lookup-orleans-runtime-grainid-out-orleans-runtime-grainaddress-out-int-790505ca/)

```csharp
public abstract bool LookUp(GrainId key, out GrainAddress result, out int version)
```

Looks up the cached value and version by the given key

### Parameters

- `key` (`GrainId`): key for the lookup
- `result` (`GrainAddress`): value if the key is found, undefined otherwise
- `version` (`int`): version of cached value if the key is found, undefined otherwise

### Returns

true if the given key is in the cache

## Remove(GrainAddress) {#remove-orleans-runtime-grainaddress-3dd313ee}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/methods/remove-orleans-runtime-grainaddress-3dd313ee/)

```csharp
public abstract bool Remove(GrainAddress key)
```

Removes an entry from the cache given its key

### Parameters

- `key` (`GrainAddress`): key to remove

### Returns

True if the entry was in the cache and the removal was successful

## Remove(GrainId) {#remove-orleans-runtime-grainid-11c96ef9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.runtime/orleans.runtime.graindirectory.igraindirectorycache/methods/remove-orleans-runtime-grainid-11c96ef9/)

```csharp
public abstract bool Remove(GrainId key)
```

Removes an entry from the cache given its key

### Parameters

- `key` (`GrainId`): key to remove

### Returns

True if the entry was in the cache and the removal was successful
