Last active
June 30, 2021 07:12
-
-
Save gistlyn/87ad14b2e2a43602cc48f5da50628dba to your computer and use it in GitHub Desktop.
redis-connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AppHost : AppHostBase | |
{ | |
public AppHost() : base("Web", | |
typeof(MyServices).Assembly) { } | |
public override void Configure(Container container) | |
{ | |
var connectionString = "redis://localhost:6379"; | |
// Register client manager. | |
container.Register<IRedisClientsManager>( | |
new RedisManagerPool(connectionString)); | |
// Register client factory | |
container.Register(c => | |
c.Resolve<IRedisClientsManager>().GetCacheClient()); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyServices : Service | |
{ | |
public object Any(Hello request) | |
{ | |
var name = Cache.Get<string>(key); | |
return new HelloResponse { | |
Result = $"Hello, {name}!" | |
}; | |
} | |
public async Task<object> Any(HelloAsync request) | |
{ | |
var name = await CacheAsync.GetAsync<string>(key); | |
return new HelloResponse { | |
Result = $"Hello, {name}!" | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment