{"id":13494052,"url":"https://github.com/8treenet/gcache","last_synced_at":"2025-09-09T23:15:48.676Z","repository":{"id":45722646,"uuid":"208251112","full_name":"8treenet/gcache","owner":"8treenet","description":"gcache是gorm的中间件，插入后gorm即刻拥有缓存。","archived":false,"fork":false,"pushed_at":"2021-11-17T06:42:50.000Z","size":99,"stargazers_count":388,"open_issues_count":2,"forks_count":52,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-05-25T18:06:36.545Z","etag":null,"topics":["cache","gcache","gorm","gorm-cache"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/8treenet.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":"2019-09-13T11:27:41.000Z","updated_at":"2025-04-13T03:41:23.000Z","dependencies_parsed_at":"2022-08-12T12:10:12.534Z","dependency_job_id":null,"html_url":"https://github.com/8treenet/gcache","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/8treenet/gcache","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8treenet%2Fgcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8treenet%2Fgcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8treenet%2Fgcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8treenet%2Fgcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/8treenet","download_url":"https://codeload.github.com/8treenet/gcache/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/8treenet%2Fgcache/sbom","scorecard":{"id":6163,"data":{"date":"2025-08-11","repo":{"name":"github.com/8treenet/gcache","commit":"7ac304312b7f0c6547b2f599d84c857ea7855bde"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":1,"reason":"Found 3/27 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 6 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-14T13:36:03.686Z","repository_id":45722646,"created_at":"2025-08-14T13:36:03.686Z","updated_at":"2025-08-14T13:36:03.686Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274380175,"owners_count":25274326,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"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":["cache","gcache","gorm","gorm-cache"],"created_at":"2024-07-31T19:01:21.285Z","updated_at":"2025-09-09T23:15:48.649Z","avatar_url":"https://github.com/8treenet.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# gcache\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/8treenet/freedom/blob/master/LICENSE) [![Go Report Card](https://goreportcard.com/badge/github.com/8treenet/freedom)](https://goreportcard.com/report/github.com/8treenet/freedom) [![Build Status](https://travis-ci.org/8treenet/gotree.svg?branch=master)](https://travis-ci.org/8treenet/gotree) [![GoDoc](https://godoc.org/github.com/8treenet/freedom?status.svg)](https://godoc.org/github.com/8treenet/freedom) \n\n###### gcache是gorm的中间件，插入后gorm即刻拥有缓存。\n\n## Overview\n- 即插即用\n- 旁路缓存\n- 数据源使用 Redis\n- 防击穿\n- 防穿透\n\n#### 安装\n```sh\n$ go get github.com/8treenet/gcache\n```\n#### 快速使用\n```go\nimport (\n    \"github.com/8treenet/gcache\"\n    \"github.com/jinzhu/gorm\"\n    \"github.com/8treenet/gcache/option\"\"\n)\n\nfunc init() {\n    //创建 gorm.DB\n    db, _ = gorm.Open(\"mysql\", \"\")\n\n    opt := option.DefaultOption{}\n    opt.Expires = 300                //缓存时间, 默认120秒。范围30-43200\n    opt.Level = option.LevelSearch   //缓存级别，默认LevelSearch。LevelDisable:关闭缓存，LevelModel:模型缓存， LevelSearch:查询缓存\n    opt.AsyncWrite = false           //异步缓存更新, 默认false。 insert update delete 成功后是否异步更新缓存。 ps: affected如果未0，不触发更新。\n    opt.PenetrationSafe = false \t //开启防穿透, 默认false。 ps:防击穿强制全局开启。\n    \n    //缓存中间件附加到gorm.DB\n    gcache.AttachDB(db, \u0026opt, \u0026option.RedisOption{Addr:\"localhost:6379\"})\n}\n```\n\n#### 约定\n- 模型必须指明主键 `gorm:\"primary_key\"`\n- 不支持 Group\n- 不支持 Having\n- 查询条件和查询参数分离\n\n\n#### [Example](https://github.com/8treenet/gcache/blob/master/example/example_test.go)\n```shell script\n    #查看 example_test.go 了解更多。\n    more src/github.com/8treenet/gcache/example/example_test.go\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8treenet%2Fgcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F8treenet%2Fgcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F8treenet%2Fgcache/lists"}