Skip to content

Commit f300d88

Browse files
Merge pull request #666 from johelvisguzman/GH-613
GH-613
2 parents 69202ac + 3208582 commit f300d88

40 files changed

+1286
-1332
lines changed

src/DotNetToolkit.Repository.Caching.Couchbase/CouchbaseCache.cs

Lines changed: 0 additions & 139 deletions
This file was deleted.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
namespace DotNetToolkit.Repository.Caching.Couchbase
2+
{
3+
using JetBrains.Annotations;
4+
using System;
5+
using Utility;
6+
7+
/// <summary>
8+
/// The options to be used by the couchbase caching provider.
9+
/// </summary>
10+
public class CouchbaseCacheOptions
11+
{
12+
private string _host;
13+
private string _bucketName;
14+
private string _username;
15+
private string _password;
16+
private TimeSpan? _expiry;
17+
18+
/// <summary>
19+
/// Gets the host.
20+
/// </summary>
21+
public string Host { get { return _host; } }
22+
23+
/// <summary>
24+
/// Gets the bucket name.
25+
/// </summary>
26+
public string BucketName { get { return _bucketName; } }
27+
28+
/// <summary>
29+
/// Gets the username.
30+
/// </summary>
31+
public string Username { get { return _username; } }
32+
33+
/// <summary>
34+
/// Gets the password.
35+
/// </summary>
36+
public string Password { get { return _password; } }
37+
38+
/// <summary>
39+
/// Gets the expiration time.
40+
/// </summary>
41+
public TimeSpan? Expiry { get { return _expiry; } }
42+
43+
/// <summary>
44+
/// Adds the giving bucketname to the options.
45+
/// </summary>
46+
/// <param name="bucketname">The bucketname to be added.</param>
47+
public CouchbaseCacheOptions WithBucketName([NotNull] string bucketname)
48+
{
49+
_bucketName = Guard.NotEmpty(bucketname, nameof(bucketname));
50+
51+
return this;
52+
}
53+
54+
/// <summary>
55+
/// Adds the giving username to the options.
56+
/// </summary>
57+
/// <param name="username">The username to be added.</param>
58+
public CouchbaseCacheOptions WithUsername([NotNull] string username)
59+
{
60+
_username = Guard.NotEmpty(username, nameof(username));
61+
62+
return this;
63+
}
64+
65+
/// <summary>
66+
/// Adds the giving password to the options.
67+
/// </summary>
68+
/// <param name="password">The password to be added.</param>
69+
public CouchbaseCacheOptions WithPassword([NotNull] string password)
70+
{
71+
_password = Guard.NotEmpty(password, nameof(password));
72+
73+
return this;
74+
}
75+
76+
/// <summary>
77+
/// Adds the giving endpoint to the options.
78+
/// </summary>
79+
/// <param name="host">The host to be added.</param>
80+
/// <param name="port">The port to be added.</param>
81+
public CouchbaseCacheOptions WithEndPoint([NotNull] string host, int port)
82+
{
83+
Guard.NotEmpty(host, nameof(host));
84+
85+
_host = string.Format("{0}:{1}", host, port);
86+
87+
return this;
88+
}
89+
90+
/// <summary>
91+
/// Adds the giving endpoint to the options.
92+
/// </summary>
93+
/// <param name="hostAndPort">The host and port to be added.</param>
94+
public CouchbaseCacheOptions WithEndPoint([NotNull] string hostAndPort)
95+
{
96+
_host = Guard.NotEmpty(hostAndPort, nameof(hostAndPort));
97+
98+
return this;
99+
}
100+
101+
/// <summary>
102+
/// Adds the giving caching expiration time to the options.
103+
/// </summary>
104+
/// <param name="expiry">The caching expiration time to be added.</param>
105+
public CouchbaseCacheOptions WithExpiry([NotNull] TimeSpan expiry)
106+
{
107+
_expiry = Guard.NotNull(expiry, nameof(expiry));
108+
109+
return this;
110+
}
111+
}
112+
}

0 commit comments

Comments
 (0)