/* * Copyright (c) 2024 Vaughn Nugent * * Library: VNLib * Package: VNLib.Data.Caching.ObjectCache * File: IPersistantCacheStore.cs * * IPersistantCacheStore.cs is part of VNLib.Data.Caching.ObjectCache which * is part of the larger VNLib collection of libraries and utilities. * * VNLib.Data.Caching.ObjectCache is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * VNLib.Data.Caching.ObjectCache is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see https://www.gnu.org/licenses/. */ using System; namespace VNLib.Data.Caching.ObjectCache { /// /// Provides a persitance layer to memory caching. /// public interface IPersistantCacheStore : IDisposable { /// /// Invoked when an entry has been evicted from main-memory cache /// and is expected to be stored in a "persistant" storage solution. /// /// When this method returns, the is no longer valid. /// /// /// This method is called while the bucket lock is held. This call is maded /// during an method call. /// /// /// The id of the bucket requesting the operation /// The key identifying the the entry /// The entry containing the object data to store void OnEntryEvicted(uint bucketId, string key, in CacheEntry entry); /// /// Called when a cache item does not exist in main memory cache and should /// be promoted from persistant cache to main memory cache. /// /// This method is called while the bucket lock is held. This call is maded /// during an method call. /// /// /// The key identifying the entry to promot /// The cache table memory manager /// The id of the bucket requesting the operation /// The newly created entry when data is found /// /// A value inidcating if the entry was successfully recovered from the persistant storage and /// was successfully promoted. /// bool OnCacheMiss(uint bucketId, string key, ICacheEntryMemoryManager memManager, out CacheEntry entry); /// /// Removes an entry from the backing store /// /// The key identifying the entry to remove /// The id of the bucket requesting the operation void OnEntryDeleted(uint bucketId, string key); } }