EasyCache.Core 1.0.1

dotnet add package EasyCache.Core --version 1.0.1
NuGet\Install-Package EasyCache.Core -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EasyCache.Core" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EasyCache.Core --version 1.0.1
#r "nuget: EasyCache.Core, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install EasyCache.Core as a Cake Addin
#addin nuget:?package=EasyCache.Core&version=1.0.1

// Install EasyCache.Core as a Cake Tool
#tool nuget:?package=EasyCache.Core&version=1.0.1

✨EasyCache.Core

Welcome EasyCache.Core documentation.

This package includes base methods for EasyCache.

    /// <summary>
    /// This interface base methods for Cache
    /// </summary>
    public interface IEasyCacheService
    {
        /// <summary>
        /// Set Cache
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        /// <param name="value">
        /// Object to be cached
        /// </param>
        /// <param name="expireTime">
        /// Cache Expire time
        /// </param>
        void Set<T>(string key, T value, TimeSpan expireTime);
        /// <summary>
        /// Set cache async version
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        /// <param name="value">
        /// Object to be cached
        /// </param>
        /// <param name="expireTime">
        /// Cache Expire time</param>
        /// <returns>
        /// System.Threading.Tasks.Task
        /// </returns>
        Task SetAsync<T>(string key, T value, TimeSpan expireTime);

        /// <summary>
        /// Get cached object
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        /// <returns>
        /// Object to be cached
        /// </returns>
        T Get<T>(string key);

        /// <summary>
        /// Get cached object async version
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        /// <returns>
        /// Object to be cached
        /// </returns>
        Task<T> GetAsync<T>(string key);

        /// <summary>
        /// Remove cache
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        void Remove<T>(string key);

        /// <summary>
        /// Remove cache
        /// </summary>
        /// <typeparam name="T">
        /// Object to be cached
        /// </typeparam>
        /// <param name="key">
        /// Uniqe cache key
        /// </param>
        Task RemoveAsync<T>(string key);
    }

Extensions

    /// <summary>
    /// This class includes extensions method of IEasyCacheService
    /// </summary>
    public static class EasyCacheServiceExtension
    {
        public static T GetAndSet<T>(this IEasyCacheService easyCacheService, string key, Func<T> getResult, TimeSpan expireTime)
        {
            var data = easyCacheService.Get<T>(key);
            
            if (data == null)
            {
                data = getResult();
                easyCacheService.Set(key, data, expireTime);
            }

            return data;
        }

        public static Task<T> GetAndSetAsync<T>(this IEasyCacheService easyCacheService, string key, Func<Task<T>> getResult, TimeSpan expireTime)
        {
            var data = easyCacheService.Get<T>(key);

            if (data == null)
            {
                data = getResult().GetAwaiter().GetResult();
                easyCacheService.Set(key, data, expireTime);
            }

            return Task.FromResult(data);
        }
    }

See for more information github repo. EasyCache

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on EasyCache.Core:

Package Downloads
EasyCache.Memory

This library provides dynamically cache operation for MemoryCache.

EasyCache.Redis

This library provides dynamically cache operation for Redis.

EasyCache.Blob.AzureStorage

Package Description

EasyCache.MemCache

This library provides dynamically cache operation for MemCache.

EasyCache.AspNetCore

This library includes AutoCache attribute for AspNetCore.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 13,021 1/10/2021
1.0.0 987 12/30/2020

♻ Refactor Async Extensions.