{"id":34225500,"url":"https://github.com/tinh-tinh/cacher","last_synced_at":"2026-03-09T22:32:39.578Z","repository":{"id":259572827,"uuid":"877041846","full_name":"tinh-tinh/cacher","owner":"tinh-tinh","description":"⚡Cache Manager for Tinh Tinh framework","archived":false,"fork":false,"pushed_at":"2025-12-26T15:56:19.000Z","size":1909,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-28T04:19:52.299Z","etag":null,"topics":["cache","framework"],"latest_commit_sha":null,"homepage":"https://tinh-tinh.github.io/docs/docs/intergrations/cache","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tinh-tinh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-10-23T01:39:32.000Z","updated_at":"2025-12-26T15:56:23.000Z","dependencies_parsed_at":"2024-10-26T16:39:02.786Z","dependency_job_id":"af6687fc-2737-4af5-9477-3e3f5d421b32","html_url":"https://github.com/tinh-tinh/cacher","commit_stats":null,"previous_names":["tinh-tinh/cacher"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/tinh-tinh/cacher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fcacher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fcacher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fcacher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fcacher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tinh-tinh","download_url":"https://codeload.github.com/tinh-tinh/cacher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tinh-tinh%2Fcacher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30314629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cache","framework"],"created_at":"2025-12-16T00:07:47.035Z","updated_at":"2026-03-09T22:32:39.543Z","avatar_url":"https://github.com/tinh-tinh.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cache for Tinh Tinh\n\n\u003cdiv align=\"center\"\u003e\n\u003cimg alt=\"GitHub Release\" src=\"https://img.shields.io/github/v/release/tinh-tinh/cacher\"\u003e\n\u003cimg alt=\"GitHub License\" src=\"https://img.shields.io/github/license/tinh-tinh/cacher\"\u003e\n\u003ca href=\"https://codecov.io/gh/tinh-tinh/cacher\" \u003e \n \u003cimg src=\"https://codecov.io/gh/tinh-tinh/cacher/graph/badge.svg?token=5P267CM3SA\"/\u003e \n \u003c/a\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/tinh-tinh/cacher\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/tinh-tinh/cacher.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://avatars.githubusercontent.com/u/178628733?s=400\u0026u=2a8230486a43595a03a6f9f204e54a0046ce0cc4\u0026v=4\" width=\"200\" alt=\"Tinh Tinh Logo\"\u003e\n\u003c/div\u003e\n\n## Overview\n\nThe Cache Manager provides a unified API to manage caching in Tinh Tinh applications. It supports memory, Memcache, and Redis backends, and can be flexibly configured and injected into your modules and controllers.\n\n## Features\n\n- 🔌 **Pluggable Backends:** Supports in-memory, Memcache, and Redis stores\n- 🛡️ **Type Safety:** Generic interface for strong typing\n- 🏷️ **Namespace Support:** Isolate cache by logical namespace\n- 📦 **Compression:** Optional data compression\n- 🌐 **Context-aware:** Supports context propagation for advanced use cases\n- 🎣 **Hooks:** Register hooks for cache lifecycle events\n\n## Installation\n\n```bash\ngo get -u github.com/tinh-tinh/cacher/v2\n```\n\n## Basic Usage\n\n### Setting Up an In-Memory Cache\n\n```go\nimport \"github.com/tinh-tinh/cacher/v2\"\n\ncache := cacher.NewSchema[string](cacher.Config{\n    Store: cacher.NewInMemory(cacher.StoreOptions{\n        Ttl: 15 * time.Minute,\n    }),\n})\n\nerr := cache.Set(\"users\", \"John\")\ndata, err := cache.Get(\"users\")\n```\n\n### Using Namespaces\n\n```go\ncache1 := cacher.NewSchema[string](cacher.Config{\n    Store:     store,\n    Namespace: \"cache1\",\n})\ncache2 := cacher.NewSchema[string](cacher.Config{\n    Store:     store,\n    Namespace: \"cache2\",\n})\n```\n\n### Memcache Example\n\n```go\nimport \"github.com/tinh-tinh/cacher/storage/memcache\"\n\ncache := memcache.New(memcache.Options{\n    Addr: []string{\"localhost:11211\"},\n    Ttl:  15 * time.Minute,\n})\n```\n\n### Redis Example\n\n```go\nimport (\n    \"github.com/tinh-tinh/cacher/storage/redis\"\n    redis_store \"github.com/redis/go-redis/v9\"\n)\n\ncache := redis.New(redis.Options{\n    Connect: \u0026redis_store.Options{\n        Addr: \"localhost:6379\",\n    },\n    Ttl: 15 * time.Minute,\n})\n```\n\n## API Overview\n\nThe main cache interface provides:\n\n- `Set(key, value, opts...)`: Store a value\n- `Get(key)`: Retrieve a value\n- `Delete(key)`: Remove a value\n- `Clear()`: Remove all values\n- `MSet(...params)`: Batch set\n- `MGet(...keys)`: Batch get\n\n## Module Integration\n\nYou can register the cache as a provider in a Tinh Tinh module and inject it into controllers:\n\n```go\nimport (\n    \"github.com/tinh-tinh/cacher/v2\"\n    \"github.com/tinh-tinh/tinhtinh/v2/core\"\n)\n\nfunc userController(module core.Module) core.Controller {\n    cache := cacher.Inject[[]byte](module)\n    ctrl := module.NewController(\"users\")\n\n    ctrl.Get(\"\", func(ctx core.Ctx) error {\n        data, err := cache.Get(\"users\")\n        // handle data\n    })\n    return ctrl\n}\n```\n\nTo register the cache provider:\n\n```go\nmodule := core.NewModule(core.NewModuleOptions{\n    Imports: []core.Modules{\n        cacher.Register(cacher.Config{ Store: cache }),\n        userModule,\n    },\n})\n```\n\n## Advanced Features\n\n### Compression\nSet `CompressAlg` in `Config` to enable data compression:\n\n```go\ncache := cacher.NewSchema[string](cacher.Config{\n    Store: store,\n    CompressAlg: \"gzip\", // Enable compression\n})\n```\n\n### Hooks\nUse the `Hooks` field to register cache lifecycle hooks:\n\n```go\ncache := cacher.NewSchema[string](cacher.Config{\n    Store: store,\n    Hooks: []cacher.Hook{\n        // Add your hooks here\n    },\n})\n```\n\n### Context Operations\nUse `SetCtx` and `GetCtx` for context-aware operations:\n\n```go\nctx := context.Background()\nerr := cache.SetCtx(ctx, \"key\", value)\ndata, err := cache.GetCtx(ctx, \"key\")\n```\n\n## Testing\n\nThe repository includes comprehensive tests for all stores and features. See:\n- `cacher_test.go`\n- `storage/memcache/memcache_test.go`\n\n## Contributing\n\nWe welcome contributions! Please feel free to submit a Pull Request.\n\n## Support\n\nIf you encounter any issues or need help, you can:\n- Open an issue in the GitHub repository\n- Check our documentation\n- Join our community discussions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinh-tinh%2Fcacher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftinh-tinh%2Fcacher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftinh-tinh%2Fcacher/lists"}