RethinkDB.DistributedCache/src/RethinkDB.DistributedCache/IServiceCollectionExtensions.fs
Daniel J. Summers c79306078c WIP on refreshing expired sessions
- Move RethinkDB operations to their own module
- Incorporated cancellation tokens throughout
2022-04-21 21:38:51 -04:00

26 lines
1.1 KiB
Forth

/// Extensions for <see cref="IServiceCollection" /> to add the RethinkDB cache
[<AutoOpen>]
[<System.Runtime.CompilerServices.Extension>]
module RethinkDB.DistributedCache.IServiceCollectionExtensions
open Microsoft.Extensions.Caching.Distributed
open Microsoft.Extensions.DependencyInjection
open System
type IServiceCollection with
member this.AddDistributedRethinkDBCache (options : Action<DistributedRethinkDBCacheOptions>) =
if isNull options then nullArg "options"
this.AddOptions () |> ignore
this.Configure options |> ignore
this.Add (ServiceDescriptor.Singleton<IDistributedCache, DistributedRethinkDBCache> ())
this
/// <summary>
/// Add RethinkDB options to the services collection
/// </summary>
/// <param name="options">An action to set the options for the cache</param>
/// <returns>The given <see cref="IServiceCollection" /> for further manipulation</returns>
[<System.Runtime.CompilerServices.Extension>]
let AddDistributedRethinkDBCache (this : IServiceCollection, options : Action<DistributedRethinkDBCacheOptions>) =
this.AddDistributedRethinkDBCache options