{"id":19466805,"url":"https://github.com/dena/cloud-datastore-interceptor","last_synced_at":"2025-04-25T11:30:32.523Z","repository":{"id":136341444,"uuid":"214330212","full_name":"DeNA/cloud-datastore-interceptor","owner":"DeNA","description":"Interceptors for Cloud Datastore","archived":false,"fork":false,"pushed_at":"2021-06-11T09:37:53.000Z","size":39,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-03T20:05:14.157Z","etag":null,"topics":["cloud-datastore","go","google-cloud","grpc","interceptor"],"latest_commit_sha":null,"homepage":null,"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/DeNA.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}},"created_at":"2019-10-11T02:55:20.000Z","updated_at":"2024-11-14T16:09:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"ade5b3f0-a37f-4bac-aeae-ff11e3133a37","html_url":"https://github.com/DeNA/cloud-datastore-interceptor","commit_stats":null,"previous_names":["daisuzu/cloud-datastore-interceptor"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeNA%2Fcloud-datastore-interceptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeNA%2Fcloud-datastore-interceptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeNA%2Fcloud-datastore-interceptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeNA%2Fcloud-datastore-interceptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeNA","download_url":"https://codeload.github.com/DeNA/cloud-datastore-interceptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250808032,"owners_count":21490607,"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":["cloud-datastore","go","google-cloud","grpc","interceptor"],"created_at":"2024-11-10T18:30:19.495Z","updated_at":"2025-04-25T11:30:32.221Z","avatar_url":"https://github.com/DeNA.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloud-datastore-interceptor\n\n[![GoDoc](https://godoc.org/github.com/DeNA/cloud-datastore-interceptor?status.svg)](https://godoc.org/github.com/DeNA/cloud-datastore-interceptor)\n\nPackage `github.com/DeNA/cloud-datastore-interceptor` provides gRPC interceptors for Cloud Datastore([cloud.google.com/go/datastore](https://godoc.org/cloud.google.com/go/datastore)).\n\n## Examples\n\n### In-Memory cache\n\nThis will use in-memory cache on [Client.Get](https://godoc.org/cloud.google.com/go/datastore#Client.Get) and [Client.GetMulti](https://godoc.org/cloud.google.com/go/datastore#Client.GetMulti).\n\n```go\nopts := []option.ClientOption{\n\toption.WithGRPCDialOption(\n\t\tgrpc.WithUnaryInterceptor(\n\t\t\tcache.UnaryClientInterceptor(memory.NewCache(1 * time.Minute)),\n\t\t),\n\t),\n}\nclient, err := datastore.NewClient(ctx, projID, opts...)\n```\n\n### Cache query results\n\n[cache.UnaryClientInterceptor](https://godoc.org/github.com/DeNA/cloud-datastore-interceptor/cache#UnaryClientInterceptor) does not use the cache for [Query](https://godoc.org/cloud.google.com/go/datastore#Query)(e.g., [Client.GetAll](https://godoc.org/cloud.google.com/go/datastore#Client.GetAll), [Client.Run](https://godoc.org/cloud.google.com/go/datastore#Client.Run)), but by using [transform.QueryToLookupWithKeysOnly](https://godoc.org/github.com/DeNA/cloud-datastore-interceptor/transform#QueryToLookupWithKeysOnly), it is transformed to gRPC equivalent to [Client.GetMulti](https://godoc.org/cloud.google.com/go/datastore#Client.GetMulti) and the cache is used.\n\n```go\nopts := []option.ClientOption{\n\toption.WithGRPCDialOption(\n\t\tgrpc.WithChainUnaryInterceptor(\n\t\t\ttransform.QueryToLookupWithKeysOnly(),\n\t\t\tcache.UnaryClientInterceptor(memory.NewCache(1*time.Minute)),\n\t\t),\n\t),\n}\nclient, err := datastore.NewClient(ctx, projID, opts...)\n```\n\n### Redis cache\n\nSame as [In-Memory cache](#in-memory-cache), but the backend is Redis using [redisClient](https://godoc.org/github.com/go-redis/redis#Client).\n\n```go\nopts := []option.ClientOption{\n\toption.WithGRPCDialOption(\n\t\tgrpc.WithUnaryInterceptor(\n\t\t\tcache.UnaryClientInterceptor(redis.NewCache(1*time.Minute, redisClient)),\n\t\t),\n\t),\n}\nclient, err := datastore.NewClient(ctx, projID, opts...)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdena%2Fcloud-datastore-interceptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdena%2Fcloud-datastore-interceptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdena%2Fcloud-datastore-interceptor/lists"}