# RedisGrainDirectory Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/)

## Dispose {#dispose-31d1e8df}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/dispose-31d1e8df/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L194-L215)

```csharp
public void Dispose()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

## DisposeAsync {#disposeasync-580db57d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/disposeasync-580db57d/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L219-L240)

```csharp
public ValueTask DisposeAsync()
```

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

### Returns

A task that represents the asynchronous dispose operation.

## Initialize(CancellationToken) {#initialize-system-threading-cancellationtoken-5284089b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/initialize-system-threading-cancellationtoken-5284089b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L181-L190)

```csharp
public Task Initialize(CancellationToken ct = default(CancellationToken))
```

### Parameters

- `ct` (`CancellationToken`)

## Lookup(GrainId) {#lookup-orleans-runtime-grainid-d9917b49}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/lookup-orleans-runtime-grainid-d9917b49/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L48-L66)

```csharp
public Task<GrainAddress?> Lookup(GrainId grainId)
```

Lookup for a [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) for a given Grain ID.

### Parameters

- `grainId` (`GrainId`): The Grain ID to lookup

### Returns

The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) entry found in the directory, if any

## Participate(ISiloLifecycle) {#participate-orleans-runtime-isilolifecycle-15b696b4}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/participate-orleans-runtime-isilolifecycle-15b696b4/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L176-L177)

```csharp
public void Participate(ISiloLifecycle lifecycle)
```

Adds the provided observer as a participant in the lifecycle.

### Parameters

- `lifecycle` (`ISiloLifecycle`): The observer.

## Register(GrainAddress) {#register-orleans-runtime-grainaddress-1246e9e9}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/register-orleans-runtime-grainaddress-1246e9e9/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L68)

```csharp
public Task<GrainAddress?> Register(GrainAddress address)
```

Register a [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) entry in the directory. Only one [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) per [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) can be registered. If there is already an existing entry, the directory will not override it.

### Parameters

- `address` (`GrainAddress`): The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) to register

### Returns

The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) that is effectively registered in the directory.

## Register(GrainAddress, GrainAddress?) {#register-orleans-runtime-grainaddress-orleans-runtime-grainaddress-nullable-3e23c156}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/register-orleans-runtime-grainaddress-orleans-runtime-grainaddress-nullable-3e23c156/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L68)

```csharp
public Task<GrainAddress?> Register(GrainAddress address, GrainAddress? previousAddress)
```

Register a [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) entry in the directory. Only one [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) per [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) can be registered. If there is already an existing entry, the directory will not override it.

### Parameters

- `address` (`GrainAddress`): The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) to register
- `previousAddress` (`GrainAddress?`)

### Returns

The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) that is effectively registered in the directory.

## Unregister(GrainAddress) {#unregister-orleans-runtime-grainaddress-f9d142dc}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/unregister-orleans-runtime-grainaddress-f9d142dc/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L148-L167)

```csharp
public Task Unregister(GrainAddress address)
```

Unregisters the specified [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) entry from the directory.

### Parameters

- `address` (`GrainAddress`): The [GrainAddress](/orleans/docs/api/csharp/microsoft.orleans.core.abstractions/orleans.runtime.grainaddress/) to unregister.

### Returns

A `System.Threading.Tasks.Task` representing the operation.

## UnregisterSilos(List&lt;SiloAddress&gt;) {#unregistersilos-system-collections-generic-list-orleans-runtime-siloaddress-b212cc79}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.graindirectory.redis/orleans.graindirectory.redis.redisgraindirectory/methods/unregistersilos-system-collections-generic-list-orleans-runtime-siloaddress-b212cc79/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Redis/Orleans.GrainDirectory.Redis/RedisGrainDirectory.cs#L171)

```csharp
public Task UnregisterSilos(List<SiloAddress> siloAddresses)
```

Unregisters all grain directory entries which point to any of the specified silos.

### Parameters

- `siloAddresses` (`List<SiloAddress>`): The silos to be removed from the directory

### Returns

A `System.Threading.Tasks.Task` representing the operation.
