Skip to content

Commit

Permalink
ckd
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Peck committed Nov 20, 2024
1 parent 4c89a35 commit 7c55eba
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/AfterAccessPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public LongTickCountLruItem<K, V> CreateItem(K key, V value)
public void Touch(LongTickCountLruItem<K, V> item)
{
item.TickCount = this.time.Last;
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/DiscretePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Touch(LongTickCountLruItem<K, V> item)
var currentExpiry = new Duration(item.TickCount - this.time.Last);
var newExpiry = expiry.GetExpireAfterRead(item.Key, item.Value, currentExpiry);
item.TickCount = this.time.Last + newExpiry.raw;
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down
11 changes: 11 additions & 0 deletions BitFaster.Caching/Lru/LruItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ public bool WasRemoved
set => this.wasRemoved = value;
}

/// <summary>
/// Marks the item as accessed, if it was not already accessed.
/// </summary>
public void MarkAccessed()
{
if (!this.wasAccessed)
{
this.wasAccessed = true;
}
}

internal V SeqLockRead()
{
var spin = new SpinWait();
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/LruPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LruItem<K, V> CreateItem(K key, V value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Touch(LruItem<K, V> item)
{
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/TLruLongTicksPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LongTickCountLruItem<K, V> CreateItem(K key, V value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Touch(LongTickCountLruItem<K, V> item)
{
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/TlruDateTimePolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public TimeStampedLruItem<K, V> CreateItem(K key, V value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Touch(TimeStampedLruItem<K, V> item)
{
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down
2 changes: 1 addition & 1 deletion BitFaster.Caching/Lru/TlruTicksPolicy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public TickCountLruItem<K, V> CreateItem(K key, V value)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Touch(TickCountLruItem<K, V> item)
{
item.WasAccessed = true;
item.MarkAccessed();
}

///<inheritdoc/>
Expand Down

0 comments on commit 7c55eba

Please sign in to comment.