{"id":19733823,"url":"https://github.com/luca-moser/iris-cache","last_synced_at":"2025-04-30T03:32:33.169Z","repository":{"id":127160662,"uuid":"66555356","full_name":"luca-moser/iris-cache","owner":"luca-moser","description":"Caching middleware for the iris web framework.","archived":false,"fork":false,"pushed_at":"2017-11-11T07:14:10.000Z","size":10,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T22:05:11.517Z","etag":null,"topics":["cache","go","golang","iris"],"latest_commit_sha":null,"homepage":"","language":"Go","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/luca-moser.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}},"created_at":"2016-08-25T12:18:56.000Z","updated_at":"2019-10-09T06:20:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"e994ee9c-4db9-462f-8f03-81e17387dfef","html_url":"https://github.com/luca-moser/iris-cache","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/luca-moser%2Firis-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Firis-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Firis-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luca-moser%2Firis-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luca-moser","download_url":"https://codeload.github.com/luca-moser/iris-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251635743,"owners_count":21619287,"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","go","golang","iris"],"created_at":"2024-11-12T00:33:58.079Z","updated_at":"2025-04-30T03:32:33.163Z","avatar_url":"https://github.com/luca-moser.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Caching middleware for the [iris](https://github.com/kataras/iris) web framework ![](https://travis-ci.org/luca-moser/iris-cache.svg)\n\nThis middleware automatically caches the computed response (per route) for the given duration.\nA store can be defined which handles the storing and retrieving of cached data. \nThe route is not executed when the response is cached as the result is returned immediately by the middleware.\n\nStores:\n* implemented:\n    * In-memory\n    * Redis\n* planned:\n    * Flatfile\n\n### Usage\n\n```go\n// cache the data in-memory\ninMemoryStore := cache.NewInMemoryStore()\n\n// middleware configuration\ncacheConfig := cache.CacheConfig{\n    // automatically remove the cached data after the given cache time duration.\n    // if AutoRemove is to false, the cached data will be removed/refreshed up on the first route\n    // call after the cache time duration expired.\n    AutoRemove:        false,\n    // the expire time of the cached data\n    CacheTimeDuration: time.Duration(5) * time.Minute,\n    // defines the content type which will be cached\n    ContentType:       cache.ContentTypeJSON, // cache json responses\n    // (!) important: must be set to true if iris' gzip is enabled\n    IrisGzipEnabled:   false,\n    // you can supply your own cache key generator by implementing `cache.CacheKeySupplier`\n    CacheKeyFunc: cache.RequestPathToMD5 // default if non supplied\n}\n\n// as global middleware (iris.Handler), caching every response with a JSON content type\niris.Use(cache.NewCache(cacheConfig, inMemoryStore))\n\n// OR\n\n// as iris.HandlerFunc for specific routes\niris.Get(\"/json\", cache.NewCacheHF(cacheConfig, inMemoryStore), func(c *iris.Context) {\n    someStructWithJSONTags := something()\n    c.JSON(http.StatusOK, someStructWithJSONTags) // gets cached automatically\n})\n```\n\n```go\n// the cache key which will be used can be obtained from the current iris.Context\ncacheKey := ctx.Get(cache.CtxIrisCacheKey).(string)\n\n// the cached data can be invalidated by using the obtained cache key\ncache.Invalidate(cacheKey)\n```\n\n### Licence\n\n```\nMIT License\n\nCopyright (c) 2016 Luca Moser\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-moser%2Firis-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluca-moser%2Firis-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluca-moser%2Firis-cache/lists"}