{"id":18656549,"url":"https://github.com/zendesk/memflash","last_synced_at":"2025-04-11T17:32:19.526Z","repository":{"id":623799,"uuid":"263705","full_name":"zendesk/memflash","owner":"zendesk","description":"Transparent Rails.cache backend for FlashHash when the values are too big to fit in a cookie.","archived":false,"fork":false,"pushed_at":"2024-06-04T22:43:43.000Z","size":85,"stargazers_count":10,"open_issues_count":1,"forks_count":3,"subscribers_count":423,"default_branch":"main","last_synced_at":"2025-03-25T16:51:35.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/zendesk.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}},"created_at":"2009-07-29T16:08:00.000Z","updated_at":"2024-05-20T17:08:49.000Z","dependencies_parsed_at":"2024-05-20T18:25:53.124Z","dependency_job_id":null,"html_url":"https://github.com/zendesk/memflash","commit_stats":{"total_commits":63,"total_committers":12,"mean_commits":5.25,"dds":0.8253968253968254,"last_synced_commit":"f43e126d36b4a5e00b5aa8c25d3a8c1fedf8136e"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fmemflash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fmemflash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fmemflash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zendesk%2Fmemflash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zendesk","download_url":"https://codeload.github.com/zendesk/memflash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248449911,"owners_count":21105584,"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":[],"created_at":"2024-11-07T07:23:56.776Z","updated_at":"2025-04-11T17:32:18.244Z","avatar_url":"https://github.com/zendesk.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/zendesk/memflash/workflows/test/badge.svg?branch=main)](https://github.com/zendesk/memflash/actions)\n\nMemflash is a gem which enables storing really long values in the Rails FlashHash\nwithout writing them to the session. Instead, it transparently uses `Rails.cache`, thus\nenabling the flash in your actions to contain large values, and still fit in a cookie-based\nsession store.\n\n## How do I use it?\n\nMemflash is completely transparent -- requiring the gem automatically enhances FlashHash\nwith caching-enabled reads and writes.\n\nBy default, any message that is over 300 characters long, will be saved in Rails.cache,\nand a pointer to it stored in the flash. You can change this anywhere in your app by:\n\n```ruby\nMemflash.threshold = #{length-at-which-writing-to-the-cache-is-trigerred}\n```\n\n## How does it work?\n\nMemflash ties into the `[]` and `[]=` methods of Rails's FlashHash. On writes, if the value\nbeing written has a length over Memflash.threshold, Memflash generates a pseudo-random\nkey for it, writes the pseudo-random key and original value to `Rails.cache`, and stores\nthe original key and pseudo-random key in the flash. Conceptually, when you write\n`flash[:error] = \"some message\"`, this is equivalent to:\n\n```ruby\nif \"some message\".length \u003e=  Memflash.threshold\n  # generate a psedudo-random key, memflash_key\n  # write memflash_key, \"some message\" to Rails.cache\n  # write :error, memflash_key to the flash\nelse\n  # write :error, \"some message\" to the flash, as usual\nend\n```\n\nOn the flip side, reading from the flash, `flash[:error]` is conceptually equivalent to:\n\n```ruby\nif the value for :error stored in the flash is a memflash key\n  # read the original (large) value from Rails.cache\n  # return the original (large) value\nelse\n  # return the value stored in the flash, as usual\nend\n```\n\n## Author\n\nAuthored by [Vladimir Andrijevik](mailto:vladimir@zendesk.com)\n\n## Copyright and license\n\nCopyright 2013 Zendesk\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fmemflash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzendesk%2Fmemflash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzendesk%2Fmemflash/lists"}