{"id":22025175,"url":"https://github.com/drexed/lite-memoize","last_synced_at":"2026-01-19T04:01:15.802Z","repository":{"id":52064039,"uuid":"193578159","full_name":"drexed/lite-memoize","owner":"drexed","description":"Cache and memoization helpers for ruby Ruby classes","archived":false,"fork":false,"pushed_at":"2024-08-02T13:39:54.000Z","size":52,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-09T15:13:40.519Z","etag":null,"topics":["cache","memoize","ruby"],"latest_commit_sha":null,"homepage":"http://drexed.github.io/lite-memoize","language":"Ruby","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/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-06-24T20:48:55.000Z","updated_at":"2022-05-09T20:02:30.000Z","dependencies_parsed_at":"2024-11-30T07:14:53.573Z","dependency_job_id":"9fd666a7-afe4-44e2-9990-500ab639188a","html_url":"https://github.com/drexed/lite-memoize","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.027027027027026973","last_synced_commit":"fd897ad40692282ad98727455064b2036d0545b0"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/drexed/lite-memoize","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-memoize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-memoize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-memoize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-memoize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-memoize/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-memoize/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28561602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T03:31:16.861Z","status":"ssl_error","status_checked_at":"2026-01-19T03:31:15.069Z","response_time":67,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","memoize","ruby"],"created_at":"2024-11-30T07:14:48.374Z","updated_at":"2026-01-19T04:01:15.780Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite::Memoize\n\n[![Gem Version](https://badge.fury.io/rb/lite-memoize.svg)](http://badge.fury.io/rb/lite-memoize)\n[![Build Status](https://travis-ci.org/drexed/lite-memoize.svg?branch=master)](https://travis-ci.org/drexed/lite-memoize)\n\nLite::Memoize provides an API for caching and memoizing locally expensive calculations including those with parameters. The flexible API allows you to memoize results using alias, class, instance, table, or variable based cache.\n\n**NOTE:** If you are coming from `ActiveMemoize`, please read the [port](#port) section.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-memoize'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-memoize\n\n## Table of Contents\n\n* [Alias](#alias)\n* [Klass](#klass)\n* [Instance](#instance)\n* [Table](#table)\n* [Variable](#variable)\n* [Benchmarks](#benchmarks)\n* [Port](#port)\n\n## Alias\n\nAlias based memoization is the fastest of the available methods, and provides a decent level\nof control. It's the only one that can also be used to memoize class level methods. Method\narguments are automatically watched to cache dynamic values.\n\nYou can only cache results without access to any information about the `store`.\n\n```ruby\nclass Movies\n  extend Lite::Memoize::Alias\n\n  class \u003c\u003c self\n    extend Lite::Memoize::Alias\n\n    def random\n      HTTP.get('http://movies.com/any')\n    end\n\n    memoize :random\n  end\n\n  def random\n    HTTP.get('http://movies.com/any')\n  end\n\n  # NOTE: memoize must be before alias\n  memoize :random\n  alias rando random\n\n  def search(title)\n    HTTP.get(\"http://movies.com?title=#{title}\")\n  end\n\n  memoize :search, as: :find\n\nend\n\n# NOTE: To reload a method just append the reload argument key\nMovies.random               #=\u003e Cached\nMovies.random(reload: true) #=\u003e New value\n\n# NOTE: To flush the entire cache\nMovies.clear_cache #=\u003e New value\n```\n\n## Klass\n\nClass based memoization is the quickest way to get up without polluting your class with new methods.\nIt's perfect for short lived or non-altering items like `activerecord` objects.\n\nYou can only cache results without access to any information about the `store`.\n\n```ruby\nclass Movies\n  extend Lite::Memoize::Klass\n\n  def random\n    HTTP.get('http://movies.com/any')\n  end\n\n  # NOTE: memoize must be before alias\n  memoize :random\n  alias rando random\n\n  def search(title)\n    HTTP.get(\"http://movies.com?title=#{title}\")\n  end\n\n  memoize :search, as: :find\n\nend\n```\n\n## Instance\n\nInstance based memoization is the slowest of the available methods, but it provides\nthe most amount of flexibility and control. It's very useful for creating services or things\nwhere control is paramount like clearing the cache or dumping it to JSON. Method arguments\nare automatically watched to cache dynamic values. Please read the spec suite to see all\navailable actions.\n\nYou can access almost all methods in the `instance.rb` file.\n\n```ruby\nclass Movies\n\n  def cache\n    @cache ||= Lite::Memoize::Instance.new\n  end\n\n  # NOTE: This method gets all relevent info like name and args automatically\n  def all\n    cache.memoize { HTTP.get(\"http://movies.com/all\") }\n  end\n\n  def random(type)\n    cache['random'] ||= HTTP.get(\"http://movies.com/any?type=#{type}\")\n  end\n\n  alias rando random\n\n  # NOTE: Arguments in the memoize method are optional\n  def search(title)\n    cache.memoize(as: :find, args: [title], reload: !cache.empty?) do\n      HTTP.get(\"http://movies.com?title=#{title}\")\n    end\n  end\n\nend\n```\n\n## Variable\n\nVariable based memoization is lean but pollute the class with variables.\n\n```ruby\nclass Movies\n  include Lite::Memoize::Variable\n\n  def all\n    memoize(:all) { HTTP.get(\"http://movies.com/all\") }\n  end\n\n  alias full all\n\n  # NOTE: Arguments in the memoize method are optional with the exception of method name\n  def search(title)\n    memoize(:find, args: [title], reload: false) do\n      HTTP.get(\"http://movies.com?title=#{title}\")\n    end\n  end\n\nend\n```\n\n## Table\n\nTable based memoization is the leanest of the available methods, and provides a decent level\nof control. Useful when you want to keep your class light weight.\n\nYou can access all methods to the `Hash` class.\n\n```ruby\nclass Movies\n  include Lite::Memoize::Table\n\n  def all\n    memoize(:all) { HTTP.get(\"http://movies.com/all\") }\n  end\n\n  alias full all\n\n  # NOTE: Arguments in the memoize method are optional with the exception of method name\n  def search(title)\n    memoize(:find, args: [title], reload: false) do\n      HTTP.get(\"http://movies.com?title=#{title}\")\n    end\n  end\n\nend\n```\n\n## Benchmarks\n\nThe classes ranked from fastest to slowest are `Alias`, `Table`, `Klass`, `Variable`, and `Instance`.\n\nView how each compares to other libs by running the [benchmarks](https://github.com/drexed/lite-statistics/tree/master/benchmarks).\n\n## Port\n\n`Lite::Memoize` is a compatible port of [ActiveMemoize](https://github.com/drexed/active_memoize).\n\nSwitching is as easy as renaming `ActiveMemoize::Klass` to `Lite::Memoize::Klass`\nand  `ActiveMemoize::Instance` to `Lite::Memoize::Instance`.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lite-memoize. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Lite::Memoize project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lite-memoize/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-memoize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-memoize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-memoize/lists"}