Skip to content

Commit

Permalink
⚗️ disable write-to-disk for temp redis via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffynuts committed Oct 11, 2023
1 parent cad8ee4 commit 0eda694
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions source/TempDb/PeanutButter.TempRedis/TempRedis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public interface ITempRedis : IDisposable
/// </summary>
/// <returns></returns>
ConnectionMultiplexer Connect();

/// <summary>
/// Connect to the redis instance with your own options
/// </summary>
Expand Down Expand Up @@ -96,6 +96,8 @@ public interface ITempRedis : IDisposable
/// </summary>
public class TempRedisOptions
{
public const string ENV_VAR_DISABLE_DISK = "TEMPREDIS_DISABLE_DISK";

Check warning on line 99 in source/TempDb/PeanutButter.TempRedis/TempRedis.cs

View workflow job for this annotation

GitHub Actions / main

Missing XML comment for publicly visible type or member 'TempRedisOptions.ENV_VAR_DISABLE_DISK'

Check warning on line 99 in source/TempDb/PeanutButter.TempRedis/TempRedis.cs

View workflow job for this annotation

GitHub Actions / main

Missing XML comment for publicly visible type or member 'TempRedisOptions.ENV_VAR_DISABLE_DISK'

Check warning on line 99 in source/TempDb/PeanutButter.TempRedis/TempRedis.cs

View workflow job for this annotation

GitHub Actions / main

Missing XML comment for publicly visible type or member 'TempRedisOptions.ENV_VAR_DISABLE_DISK'

Check warning on line 99 in source/TempDb/PeanutButter.TempRedis/TempRedis.cs

View workflow job for this annotation

GitHub Actions / main

Missing XML comment for publicly visible type or member 'TempRedisOptions.ENV_VAR_DISABLE_DISK'

/// <summary>
/// Auto-start the service on construction? (default true)
/// </summary>
Expand All @@ -120,7 +122,12 @@ public class TempRedisOptions
/// Enables save-to-disk, which means redis-server should
/// (mostly) survive a crash.
/// </summary>
public bool EnableSaveToDisk { get; set; } = true;
public bool EnableSaveToDisk { get; set; } =
(
Environment.GetEnvironmentVariable(ENV_VAR_DISABLE_DISK)
?? "1"
)
.AsBoolean();

/// <summary>
/// When enabled (default), only bind to 127.0.0.1
Expand Down

0 comments on commit 0eda694

Please sign in to comment.