Added README
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
# Telegrator.RedisStateStorage
|
||||||
|
|
||||||
|
**Telegrator.RedisStateStorage** is an extension for the Telegrator framework that provides Redis powered IStateStorage implementation.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
- .NET standart 2.1 or later
|
||||||
|
- [Telegrator](https://github.com/Rikitav/Telegrator)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
```shell
|
||||||
|
dotnet add package Telegrator.RedisStateStorage
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Quick Start Example
|
||||||
|
|
||||||
|
**Program.cs:**
|
||||||
|
```csharp
|
||||||
|
using Telegrator.Hosting;
|
||||||
|
|
||||||
|
// Creating builder
|
||||||
|
TelegramBotHostBuilder builder = TelegramBotHost.CreateBuilder(new HostApplicationBuilderSettings()
|
||||||
|
{
|
||||||
|
Args = args,
|
||||||
|
ApplicationName = "TelegramBotHost example",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Registerring handlers
|
||||||
|
builder.Handlers.CollectHandlersAssemblyWide();
|
||||||
|
|
||||||
|
// Register your services and
|
||||||
|
builder.Services.AddService<IStateStorage, RedisStateStorage>(services =>
|
||||||
|
new RedisStateStorage(ConnectionMultiplexer.Connect("server1:6379, server2:6379")));
|
||||||
|
|
||||||
|
// Building and running application
|
||||||
|
TelegramBotHost telegramBot = builder.Build();
|
||||||
|
telegramBot.SetBotCommands();
|
||||||
|
telegramBot.Run();
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
- [Telegrator Main Docs](https://github.com/Rikitav/Telegrator)
|
||||||
|
- [Getting Started Guide](https://github.com/Rikitav/Telegrator/wiki/Getting-started)
|
||||||
|
- [Annotation Overview](https://github.com/Rikitav/Telegrator/wiki/Annotation-overview)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## License
|
||||||
|
GPLv3
|
||||||
@@ -16,7 +16,7 @@ public class RedisStateStorage(IConnectionMultiplexer redis) : IStateStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<T?> GetAsync<T>(string key, CancellationToken cancellationToken) where T : default
|
public async Task<T?> GetAsync<T>(string key, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
RedisValue json = await _db.StringGetAsync(key);
|
RedisValue json = await _db.StringGetAsync(key);
|
||||||
string? jsonStr = json;
|
string? jsonStr = json;
|
||||||
|
|||||||
Reference in New Issue
Block a user