// MIT License - Copyright (c) 2026 wallstop
// Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE
namespace WallstopStudios.UnityHelpers.Core.DataStructure
{
using System;
///
/// Specifies the eviction algorithm used by a to determine
/// which entries to remove when the cache reaches capacity.
///
///
/// Different policies offer trade-offs between hit rate, implementation complexity, and memory overhead:
///
/// - : Good general-purpose choice, O(1) operations, low memory overhead.
/// - : Better hit rate for mixed workloads, protects frequently-accessed items.
/// - : Optimal for stable access patterns, evicts least-frequently-used items.
/// - : Simplest policy, evicts in insertion order regardless of access.
/// - : Unpredictable eviction, useful for adversarial workloads.
///
///
public enum EvictionPolicy
{
///
/// Reserved for uninitialized state. Do not use directly.
///
[Obsolete("Use Lru for standard least-recently-used eviction.")]
None = 0,
///
/// Least Recently Used: Evicts the entry that has not been accessed for the longest time.
/// Provides O(1) get/set operations with low memory overhead.
///
Lru = 1,
///
/// Segmented LRU: Divides cache into probation and protected segments.
/// Newly inserted items start in probation; accessing them promotes to protected.
/// Eviction first targets probation, then demotes from protected.
/// Better hit rate than LRU for mixed workloads.
///
Slru = 2,
///
/// Least Frequently Used: Evicts the entry with the lowest access count.
/// Ties are broken by recency. Best for stable, predictable access patterns.
///
Lfu = 3,
///
/// First In First Out: Evicts entries in the order they were inserted.
/// Access does not affect eviction order. Simplest implementation.
///
Fifo = 4,
///
/// Random: Evicts a randomly selected entry when capacity is exceeded.
/// Useful for adversarial workloads or when access patterns are unpredictable.
///
Random = 5,
}
}