{"id":22080151,"url":"https://github.com/teng231/smartcache","last_synced_at":"2025-03-23T20:44:18.866Z","repository":{"id":57655892,"uuid":"454799721","full_name":"teng231/smartcache","owner":"teng231","description":"[deprecated] smart cache support memory insert, queryable and can add hook to remote cache save.","archived":false,"fork":false,"pushed_at":"2022-02-13T18:19:24.000Z","size":18,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T04:20:21.439Z","etag":null,"topics":["cache","caching","inmemory","inmemory-cache","remote-caching"],"latest_commit_sha":null,"homepage":"","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/teng231.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}},"created_at":"2022-02-02T14:09:18.000Z","updated_at":"2022-10-22T14:59:32.000Z","dependencies_parsed_at":"2022-09-02T13:21:07.443Z","dependency_job_id":null,"html_url":"https://github.com/teng231/smartcache","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Fsmartcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Fsmartcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Fsmartcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teng231%2Fsmartcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teng231","download_url":"https://codeload.github.com/teng231/smartcache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245168817,"owners_count":20571799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","caching","inmemory","inmemory-cache","remote-caching"],"created_at":"2024-11-30T23:12:41.383Z","updated_at":"2025-03-23T20:44:18.837Z","avatar_url":"https://github.com/teng231.png","language":"Go","readme":"# SmartCache\n\u003e Upgrade from my dumbcache\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/princjef/gomarkdoc.svg)](https://pkg.go.dev/github.com/teng231/smartcache)\n[![Go](https://github.com/teng231/smartcache/actions/workflows/go.yml/badge.svg?branch=master)](https://github.com/teng231/smartcache/actions/workflows/go.yml)\n\nHope it can be tool to help your works.\n\n### Installation\n\n```bash\ngo get github.com/teng231/smartcache\n```\n\n### How it work?\n\nflow like that:\n\n\n```bash\n┌────────┐       ┌────────┐      ┌───────────────┐\n│        │       │        │      │               │\n│ Engine ├─────►│ Session├─────►│   Collection  │\n│        │       │        │      │               │\n└────────┘       └────────┘      └───────────────┘\n```\n\n* When start app you create engine. Engine define structure of collection.\n* Engine provider `select` to access module cache.\n* Session process cache or set, get value to cache, from local module or remote module\n* Collection local cache module\n\n### Example\nYou can see full example here: [Example](https://github.com/teng231/smartcache/tree/master/example)\n\n```go\n\ncache := smartcache.Start(\n    \u0026smartcache.CollectionConfig{\n        Key:      \"key1\",\n        Capacity: 100,\n    },\n)\n\nif err := cache.Select(context.TODO(), \"key1\").Upsert(\"abc\", 1); err != nil {\n    log.Print(err)\n}\nvar out1 int\ncache.Select(context.TODO(), \"key1\").Get(\"abc\", nil).Exec(\u0026out1)\nlog.Print(out1)\n\n```\n\n### Benmark Result:\nfollow link\n[https://www.cloudbees.com/blog/real-life-go-benchmarking](https://www.cloudbees.com/blog/real-life-go-benchmarking)\n```bash\n$ go test -cpuprofile=cpu.out -benchmem -memprofile=mem.out -bench=BenchmarkEngineCacheWrite -run=^a\n\ngoos: linux\ngoarch: amd64\npkg: github.com/teng231/smartcache\ncpu: Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz\nBenchmarkEngineCacheWrite/input_size_100-12         \t1000000000\t         0.0000460 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkEngineCacheWrite/input_size_1000-12        \t1000000000\t         0.0004365 ns/op\t       0 B/op\t       0 allocs/op\nBenchmarkEngineCacheWrite/input_size_74382-12       \t1000000000\t         0.05490 ns/op\t       0 B/op\t       0 allocs/op\nPASS\nok  \tgithub.com/teng231/smartcache\t0.513s\n```\n\n```bash\n$ go test -cpuprofile=cpu.out -benchmem -memprofile=mem.out -bench=BenchmarkEngineCachex100000W10g -run=^a\n\ngoos: linux\ngoarch: amd64\npkg: github.com/teng231/smartcache\ncpu: Intel(R) Core(TM) i5-10400 CPU @ 2.90GHz\nBenchmarkEngineCachex100000W10g-12    \t1000000000\t         0.008111 ns/op\t       0 B/op\t       0 allocs/op\nPASS\nok  \tgithub.com/teng231/smartcache\t0.229s\n```\n\n\nContributed:\n    [Quang Anh](github.com/)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteng231%2Fsmartcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteng231%2Fsmartcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteng231%2Fsmartcache/lists"}