CacheChan.Core 1.2.1

dotnet add package CacheChan.Core --version 1.2.1
                    
NuGet\Install-Package CacheChan.Core -Version 1.2.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="CacheChan.Core" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CacheChan.Core" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="CacheChan.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CacheChan.Core --version 1.2.1
                    
#r "nuget: CacheChan.Core, 1.2.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.
#addin nuget:?package=CacheChan.Core&version=1.2.1
                    
Install CacheChan.Core as a Cake Addin
#tool nuget:?package=CacheChan.Core&version=1.2.1
                    
Install CacheChan.Core as a Cake Tool

CacheChan.Core

NuGet License

CacheChan.Core é uma biblioteca de cache leve e extensível para .NET com suporte a TTL, LRU, coleta automática de métricas e uma API simples e intuitiva — tudo isso com apenas uma linha de código.


✨ Recursos

  • 🔐 Suporte opcional a métricas via API Key
  • 🧠 Política de Evicção LRU embutida
  • ⏱️ TTL (Time To Live) para valores em cache
  • 📊 Coleta automática de métricas (hits, misses, evictions)
  • 🛠️ API de uso simples com ou sem DI
  • 📦 Pronto para produção com extensibilidade

🚀 Instalação

Instale via NuGet:

dotnet add package CacheChan.Core

⚡ Uso Rápido

Criar uma instância de cache com métricas:

using CacheChan.Interfaces;
using CacheChan.Utils;

var cache = CacheFactory.CreateCache("sua-api-key-opcional");

cache.Set("usuario:123", new { Nome = "João", Idade = 25 });
var usuario = cache.Get<dynamic>("usuario:123");
cache.Remove("usuario:123");

✅ Se você fornecer uma API Key, as métricas de uso serão salvas automaticamente para visualização na dashboard.
❌ Sem API Key? Sem problema! O cache ainda funciona normalmente, só não armazenará métricas.


🧪 Exemplo Sem Métricas (uso interno/local)

var cache = CacheFactory.CreateCache(); // ou apenas ""

cache.Set("foo", "bar");
var resultado = cache.Get<string>("foo");

Exemplo de Uso

using CacheChan.Core.Configuration;
using CacheChan.Core.Interfaces;
using CacheChan.Core.Services;
using CacheChan.Core.Utils;
using System;

namespace CacheChanConsoleExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Configurações do cache
            var options = new CacheOptions
            {
                UseLru = true,  // Usando LRU
                LruCapacity = 1000,  // Capacidade do LRU
                DefaultExpirationMinutes = 30  // Expiração de 30 minutos
            };

            // Criando o cache manualmente através do CacheFactory
            var cache = CacheFactory.CreateCache(apiKey: "my-api-key", options: options);

            // Usando o cache
            cache.Set("key1", "Hello, CacheChan!");
            var value = cache.Get<string>("key1");

            Console.WriteLine($"Retrieved from cache: {value}");

            // Exemplo de uso com outro valor
            cache.Set("key2", "Goodbye, CacheChan!");
            value = cache.Get<string>("key2");
            Console.WriteLine($"Retrieved from cache: {value}");
        }
    }
}

📦 Pacote NuGet


📄 Licença

MIT © 0xviny


🤝 Contribuindo

Contribuições são bem-vindas! Veja issues abertas ou abra uma nova com ideias, bugs ou sugestões.


Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.1 170 4/13/2025
1.2.0 167 4/13/2025
1.1.0 158 4/9/2025
1.0.2 160 4/7/2025

Primeira versão estável com suporte a políticas de expiração e LRU.