Skip to content

Commit

Permalink
Check for slave when doing some operations
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed Jan 12, 2019
1 parent 5d93fc3 commit 575826f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[Bb]in/
[Oo]bj/
artifacts
.vs/

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down Expand Up @@ -48,4 +49,5 @@ _NCrunch_*
# Rider auto-generates .iml files, and contentModel.xml
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml
**/.idea/**/modules.xml

5 changes: 5 additions & 0 deletions src/Foundatio.Redis/Cache/RedisCacheClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public async Task<int> RemoveAllAsync(IEnumerable<string> keys = null) {

foreach (var endpoint in endpoints) {
var server = _options.ConnectionMultiplexer.GetServer(endpoint);
if (server.IsSlave)
continue;

try {
await server.FlushDatabaseAsync().AnyContext();
Expand Down Expand Up @@ -367,6 +369,9 @@ private async Task LoadScriptsAsync() {

foreach (var endpoint in _options.ConnectionMultiplexer.GetEndPoints()) {
var server = _options.ConnectionMultiplexer.GetServer(endpoint);
if (server.IsSlave)
continue;

_setIfHigherScript = await setIfHigher.LoadAsync(server).AnyContext();
_setIfLowerScript = await setIfLower.LoadAsync(server).AnyContext();
_incrByAndExpireScript = await incrByAndExpire.LoadAsync(server).AnyContext();
Expand Down

0 comments on commit 575826f

Please sign in to comment.