Skip to content

Commit 588b121

Browse files
fixup! Replace ICache interface by a CacheBase class
Remove a field in UpdateTimestampsCache too
1 parent e901e38 commit 588b121

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/NHibernate/Async/Cache/UpdateTimestampsCache.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public virtual Task ClearAsync(CancellationToken cancellationToken)
3131
{
3232
return Task.FromCanceled<object>(cancellationToken);
3333
}
34-
return updateTimestamps.ClearAsync(cancellationToken);
34+
return _updateTimestamps.ClearAsync(cancellationToken);
3535
}
3636

3737
//Since v5.1
@@ -60,10 +60,10 @@ public virtual async Task PreInvalidateAsync(IReadOnlyCollection<string> spaces,
6060
using (await _preInvalidate.LockAsync())
6161
{
6262
//TODO: to handle concurrent writes correctly, this should return a Lock to the client
63-
long ts = updateTimestamps.NextTimestamp() + updateTimestamps.Timeout;
63+
long ts = _updateTimestamps.NextTimestamp() + _updateTimestamps.Timeout;
6464
foreach (var space in spaces)
6565
{
66-
await (updateTimestamps.PutAsync(space, ts, cancellationToken)).ConfigureAwait(false);
66+
await (_updateTimestamps.PutAsync(space, ts, cancellationToken)).ConfigureAwait(false);
6767
}
6868

6969
//TODO: return new Lock(ts);
@@ -98,12 +98,12 @@ public virtual async Task InvalidateAsync(IReadOnlyCollection<string> spaces, Ca
9898
using (await _invalidate.LockAsync())
9999
{
100100
//TODO: to handle concurrent writes correctly, the client should pass in a Lock
101-
long ts = updateTimestamps.NextTimestamp();
101+
long ts = _updateTimestamps.NextTimestamp();
102102
//TODO: if lock.getTimestamp().equals(ts)
103103
foreach (var space in spaces)
104104
{
105105
log.Debug("Invalidating space [{0}]", space);
106-
await (updateTimestamps.PutAsync(space, ts, cancellationToken)).ConfigureAwait(false);
106+
await (_updateTimestamps.PutAsync(space, ts, cancellationToken)).ConfigureAwait(false);
107107
}
108108
}
109109
}
@@ -120,7 +120,7 @@ public virtual async Task<bool> IsUpToDateAsync(ISet<string> spaces, long timest
120120
{
121121
keys[index++] = space;
122122
}
123-
var lastUpdates = await (_batchUpdateTimestamps.GetManyAsync(keys, cancellationToken)).ConfigureAwait(false);
123+
var lastUpdates = await (_updateTimestamps.GetManyAsync(keys, cancellationToken)).ConfigureAwait(false);
124124
foreach (var lastUpdate in lastUpdates)
125125
{
126126
if (IsOutdated(lastUpdate, timestamp))

src/NHibernate/Cache/UpdateTimestampsCache.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,22 @@ namespace NHibernate.Cache
1717
public partial class UpdateTimestampsCache
1818
{
1919
private static readonly INHibernateLogger log = NHibernateLogger.For(typeof(UpdateTimestampsCache));
20-
// 6.0 TODO: type as CacheBase instead
21-
#pragma warning disable 618
22-
private readonly ICache updateTimestamps;
23-
#pragma warning restore 618
24-
private readonly CacheBase _batchUpdateTimestamps;
20+
private readonly CacheBase _updateTimestamps;
2521

2622
private readonly string regionName = typeof(UpdateTimestampsCache).Name;
2723

2824
public virtual void Clear()
2925
{
30-
updateTimestamps.Clear();
26+
_updateTimestamps.Clear();
3127
}
3228

3329
public UpdateTimestampsCache(Settings settings, IDictionary<string, string> props)
3430
{
3531
string prefix = settings.CacheRegionPrefix;
3632
regionName = prefix == null ? regionName : prefix + '.' + regionName;
3733
log.Info("starting update timestamps cache at region: {0}", regionName);
38-
updateTimestamps = settings.CacheProvider.BuildCache(regionName, props);
39-
// ReSharper disable once SuspiciousTypeConversion.Global
40-
_batchUpdateTimestamps = updateTimestamps as CacheBase ?? new ObsoleteCacheWrapper(updateTimestamps);
34+
var updateTimestamps = settings.CacheProvider.BuildCache(regionName, props);
35+
_updateTimestamps = updateTimestamps as CacheBase ?? new ObsoleteCacheWrapper(updateTimestamps);
4136
}
4237

4338
//Since v5.1
@@ -52,10 +47,10 @@ public void PreInvalidate(object[] spaces)
5247
public virtual void PreInvalidate(IReadOnlyCollection<string> spaces)
5348
{
5449
//TODO: to handle concurrent writes correctly, this should return a Lock to the client
55-
long ts = updateTimestamps.NextTimestamp() + updateTimestamps.Timeout;
50+
long ts = _updateTimestamps.NextTimestamp() + _updateTimestamps.Timeout;
5651
foreach (var space in spaces)
5752
{
58-
updateTimestamps.Put(space, ts);
53+
_updateTimestamps.Put(space, ts);
5954
}
6055

6156
//TODO: return new Lock(ts);
@@ -73,12 +68,12 @@ public void Invalidate(object[] spaces)
7368
public virtual void Invalidate(IReadOnlyCollection<string> spaces)
7469
{
7570
//TODO: to handle concurrent writes correctly, the client should pass in a Lock
76-
long ts = updateTimestamps.NextTimestamp();
71+
long ts = _updateTimestamps.NextTimestamp();
7772
//TODO: if lock.getTimestamp().equals(ts)
7873
foreach (var space in spaces)
7974
{
8075
log.Debug("Invalidating space [{0}]", space);
81-
updateTimestamps.Put(space, ts);
76+
_updateTimestamps.Put(space, ts);
8277
}
8378
}
8479

@@ -91,7 +86,7 @@ public virtual bool IsUpToDate(ISet<string> spaces, long timestamp /* H2.1 has L
9186
{
9287
keys[index++] = space;
9388
}
94-
var lastUpdates = _batchUpdateTimestamps.GetMany(keys);
89+
var lastUpdates = _updateTimestamps.GetMany(keys);
9590
foreach (var lastUpdate in lastUpdates)
9691
{
9792
if (IsOutdated(lastUpdate, timestamp))
@@ -106,7 +101,7 @@ public virtual void Destroy()
106101
{
107102
try
108103
{
109-
updateTimestamps.Destroy();
104+
_updateTimestamps.Destroy();
110105
}
111106
catch (Exception e)
112107
{

0 commit comments

Comments
 (0)