{"id":25603586,"url":"https://github.com/vogonwann/cachey","last_synced_at":"2026-06-21T02:31:11.215Z","repository":{"id":266148668,"uuid":"897539682","full_name":"vogonwann/cachey","owner":"vogonwann","description":"Cachey is a lightweight, flexible caching library for .NET applications. It supports both in-memory and persistent caching with easy integration and customization.","archived":false,"fork":false,"pushed_at":"2024-12-06T15:22:44.000Z","size":17351,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-11T02:37:55.883Z","etag":null,"topics":["caching","csharp","dotnet","persistence"],"latest_commit_sha":null,"homepage":"https://janjic.lol","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vogonwann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-02T20:02:37.000Z","updated_at":"2024-12-06T15:22:47.000Z","dependencies_parsed_at":"2024-12-02T21:34:28.481Z","dependency_job_id":null,"html_url":"https://github.com/vogonwann/cachey","commit_stats":null,"previous_names":["vogonwann/cachey"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vogonwann/cachey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogonwann%2Fcachey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogonwann%2Fcachey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogonwann%2Fcachey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogonwann%2Fcachey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vogonwann","download_url":"https://codeload.github.com/vogonwann/cachey/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vogonwann%2Fcachey/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34592050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-21T02:00:05.568Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["caching","csharp","dotnet","persistence"],"created_at":"2025-02-21T17:27:48.315Z","updated_at":"2026-06-21T02:31:11.209Z","avatar_url":"https://github.com/vogonwann.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Cachey\n\n**Cachey** is a lightweight, flexible caching library for .NET applications. It supports both in-memory and persistent caching with easy integration and customization.\n\n## Features\n\n- In-memory caching for fast and lightweight operations.\n- Persistent caching for durable data storage.\n- Automatic cleanup of expired items with customizable intervals.\n- Seamless integration with dependency injection (DI) and configuration.\n\n## Installation\n\nAdd **Cachey** to your project using your package manager:\n\n```bash\ndotnet add package Cachey\n```\n\n## Quick Start\n\n### 1. Register Cachey in DI\n\nYou can register `Cachey` in your application's DI container using the `UseCachey` method. Here's an example:\n\n```csharp\nbuilder.Services.UseCachey(builder.Configuration)\n    .AddCacheCleanupService(TimeSpan.FromHours(1));\n```\n\n- `UseCachey` integrates Cachey into your application, dynamically deciding whether to use in-memory or persistent cache based on configuration.\n- `AddCacheCleanupService` registers a background service to periodically clean up expired cache items.\n\n### 2. Configuring Persistence\n\nThe caching behavior is determined by the `Cache` section in your application's configuration file (e.g., `appsettings.json`).\n\n#### Example Configuration:\n\n```json\n{\n  \"Cache\": {\n    \"UsePersistentCache\": true\n  }\n}\n```\n\n- Set `UsePersistentCache` to `true` to enable persistent caching.\n- When persistent caching is enabled, Cachey will use a SQLite database to store cache entries.\n\n#### Using a Custom Connection String:\n\nTo specify a custom SQLite connection string, add the following to your configuration:\n\n```json\n{\n  \"Cache\": {\n    \"UsePersistentCache\": true,\n    \"ConnectionString\": \"DataSource=mycustomcache.db\"\n  }\n}\n```\n\n\u003e Cachey automatically configures a default SQLite database (`mycache.db`) if a custom connection string is not provided.\n\n### 3. Accessing Cachey in Your Code\n\nInject the `ICache` interface into your services or controllers to start using Cachey:\n\n```csharp\npublic class MyService\n{\n    private readonly ICache _cache;\n\n    public MyService(ICache cache)\n    {\n        _cache = cache;\n    }\n\n    public async Task DoWorkAsync()\n    {\n        // Store a value in the cache\n        await _cache.SetAsync(\"key\", \"value\", TimeSpan.FromMinutes(10));\n\n        // Retrieve a value from the cache\n        var cachedValue = await _cache.GetAsync\u003cstring\u003e(\"key\");\n\n        // Remove a value from the cache\n        await _cache.RemoveAsync(\"key\");\n    }\n}\n```\n\n## Adding Cleanup Service\n\nThe cleanup service automatically removes expired cache items at regular intervals. You can customize the interval like this:\n\n```csharp\nbuilder.Services.UseCachey(builder.Configuration)\n    .AddCacheCleanupService(TimeSpan.FromMinutes(30));\n```\n\n### Cleanup Behavior\n\nThe cleanup service runs periodically, based on the specified interval, to ensure expired items are removed from the cache.\n\n## Full Example\n\nHere’s a complete example of setting up Cachey in an ASP.NET Core application:\n\n### `Program.cs`\n\n```csharp\nvar builder = WebApplication.CreateBuilder(args);\n\n// Add Cachey\nbuilder.Services.UseCachey(builder.Configuration)\n    .AddCacheCleanupService(TimeSpan.FromHours(1));\n\nvar app = builder.Build();\n\napp.MapGet(\"/\", async (ICache cache) =\u003e\n{\n    // Set a cache entry\n    await cache.SetAsync(\"example\", \"Hello, Cachey!\", TimeSpan.FromMinutes(5));\n\n    // Retrieve the cached value\n    var value = await cache.GetAsync\u003cstring\u003e(\"example\");\n    return value ?? \"Cache entry not found!\";\n});\n\napp.Run();\n```\n\n### `appsettings.json`\n\n```json\n{\n  \"Cache\": {\n    \"UsePersistentCache\": true,\n    \"ConnectionString\": \"DataSource=mycustomcache.db\"\n  }\n}\n```\n\n---\n\n## License\n\nCachey is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogonwann%2Fcachey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvogonwann%2Fcachey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvogonwann%2Fcachey/lists"}