File tree Expand file tree Collapse file tree 2 files changed +42
-1
lines changed
src/DotNetToolkit.Repository.Caching.Memcached Expand file tree Collapse file tree 2 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 22
33``` csharp
44var options = new RepositoryOptionsBuilder ()
5- .UseCachingProvider ( new MemcachedCacheProvider () )
5+ .UseMemcached ( .. . )
66 .Options ;
77
88var repo = new Repository <Customer >(options );
Original file line number Diff line number Diff line change 1+ namespace DotNetToolkit . Repository . Caching . Memcached
2+ {
3+ using Configuration . Options ;
4+ using Utility ;
5+ using JetBrains . Annotations ;
6+ using System ;
7+
8+ /// <summary>
9+ /// Contains various extension methods for <see cref="RepositoryOptionsBuilder" />
10+ /// </summary>
11+ public static class RepositoryOptionsBuilderExtensions
12+ {
13+ /// <summary>
14+ /// Configures the caching provider to use memcached.
15+ /// </summary>
16+ /// <param name="source">The repository options builder.</param>
17+ /// <param name="optionsAction">The options action.</param>
18+ /// <returns>The same builder instance.</returns>
19+ public static RepositoryOptionsBuilder UseMemcached ( [ NotNull ] this RepositoryOptionsBuilder source , [ NotNull ] Action < MemcachedCacheOptions > optionsAction )
20+ {
21+ Guard . NotNull ( source , nameof ( source ) ) ;
22+ Guard . NotNull ( optionsAction , nameof ( optionsAction ) ) ;
23+
24+ var options = new MemcachedCacheOptions ( ) ;
25+
26+ optionsAction ( options ) ;
27+
28+ var provider = new MemcachedCacheProvider (
29+ options . Host ,
30+ options . Username ,
31+ options . Password ,
32+ options . Protocal ,
33+ options . AuthenticationType ,
34+ options . Expiry ) ;
35+
36+ source . UseCachingProvider ( provider ) ;
37+
38+ return source ;
39+ }
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments