Skip to content

Commit 260c356

Browse files
authored
Merge pull request #12 from PandaTechAM/development
max value support on CacheSet
2 parents a6f84e6 + 13fb493 commit 260c356

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/DistributedCache/DistributedCache.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
<PackageReadmeFile>Readme.md</PackageReadmeFile>
99
<Authors>Pandatech</Authors>
1010
<Copyright>MIT</Copyright>
11-
<Version>4.0.2</Version>
11+
<Version>4.0.3</Version>
1212
<PackageId>Pandatech.DistributedCache</PackageId>
1313
<Title>Pandatech Distributed Cache</Title>
1414
<PackageTags>pandatech;cache;hybrid-cache;distributed-cahce;message-pack;rate-limiting;redis-lock;redis;fusion-cache</PackageTags>
1515
<Description>Pandatech.DistributedCache is a lightweight .NET library that extends the new HybridCache abstraction for seamless distributed caching on top of Redis. It provides strongly typed caching with MessagePack serialization, distributed locking, rate limiting, and stampede protection. With fewer than 500 lines of code, it is both easy to understand and simple to adopt, while still offering robust features for production environments.</Description>
1616
<RepositoryUrl>https://github.com/PandaTechAM/be-lib-distributed-cache</RepositoryUrl>
17-
<PackageReleaseNotes>More overloads on string extensions</PackageReleaseNotes>
17+
<PackageReleaseNotes>TimeSpan max value support</PackageReleaseNotes>
1818
</PropertyGroup>
1919

2020
<ItemGroup>

src/DistributedCache/Services/Implementations/RedisDistributedCache.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,24 @@ public override async ValueTask SetAsync<T>(string key,
121121
}
122122

123123
var prefixedKey = CacheKeyFormatter.BuildPrefixedKey(key, _config);
124+
124125
var expirationTime = options?.Expiration ?? _config.DefaultExpiration;
126+
127+
125128
var cacheStore = new CacheStore<T>
126129
{
127130
Data = value,
128131
Tags = (tags ?? Array.Empty<string>()).ToList()
129132
};
130-
await _redisDatabase.AddAsync(prefixedKey, cacheStore, expirationTime);
133+
134+
if (expirationTime == TimeSpan.MaxValue)
135+
{
136+
await _redisDatabase.AddAsync(prefixedKey, cacheStore);
137+
}
138+
else
139+
{
140+
await _redisDatabase.AddAsync(prefixedKey, cacheStore, expirationTime);
141+
}
131142
}
132143

133144
public override async ValueTask RemoveAsync(string key, CancellationToken cancellationToken = default)

0 commit comments

Comments
 (0)