{"id":15663142,"url":"https://github.com/markbates/cachetastic","last_synced_at":"2025-05-06T06:58:43.841Z","repository":{"id":392601,"uuid":"10360","full_name":"markbates/cachetastic","owner":"markbates","description":"A very simple, yet very powerful caching framework for Ruby","archived":false,"fork":false,"pushed_at":"2022-11-21T23:56:38.000Z","size":120,"stargazers_count":18,"open_issues_count":9,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-25T16:43:43.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.mackframework.com","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/markbates.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2008-04-16T17:59:18.000Z","updated_at":"2023-11-03T21:56:19.000Z","dependencies_parsed_at":"2023-01-11T15:23:07.236Z","dependency_job_id":null,"html_url":"https://github.com/markbates/cachetastic","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fcachetastic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fcachetastic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fcachetastic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/markbates%2Fcachetastic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/markbates","download_url":"https://codeload.github.com/markbates/cachetastic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242783050,"owners_count":20184418,"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-10-03T13:35:37.582Z","updated_at":"2025-03-10T03:32:40.507Z","avatar_url":"https://github.com/markbates.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is Cachetastic?\n\nCachetastic is an incredibly easy to use and administer caching framework. Just because it is easy to use, does not mean that it is light with features. Cachetastic allows you to create classes that extend \u003ccode\u003eCachetastic::Cache\u003c/code\u003e, configure them each individually, and much more.\n\nUnlike other systems each cache in your system can use different backends via the use of adapters that get assigned to each cache, and globally. You can define different expiration times, loggers, marshal methods, and more! And again, you can choose to define these settings globally, or for each cache!\n\nAdapters are easy to write, so if the built in adapters don't float your boat, you can easily knock one off in short order.\n\n## Configuration:\n\nConfiguration of Cachetastic is done using the Configatron gem.\n\nAll configuration settings hang off of the \u003ccode\u003ecachetastic\u003c/code\u003e namespace on \u003ccode\u003econfigatron\u003c/code\u003e. The default settings all hang off the \u003ccode\u003edefaults\u003c/code\u003e namespace on the \u003ccode\u003ecachetastic\u003c/code\u003e namespace, as shown below:\n\n```ruby\n# This will write detailed information to the logger.\nconfigatron.cachetastic.defaults.debug = false\n\n# This is the type of file store to be used for this cache.\n# More adapters can be developed and plugged in as desired.\n# The default is Cachetastic::Adapters::LocalMemory\nconfigatron.cachetastic.defaults.adapter = Cachetastic::Adapters::LocalMemory\nconfigatron.cachetastic.defaults.adapter = Cachetastic::Adapters::File\nconfigatron.cachetastic.defaults.adapter = Cachetastic::Adapters::Memcached\nconfigatron.cachetastic.defaults.adapter = Cachetastic::Adapters::Redis\n\n# This will marshall objects into and out of the store.\n# The default is :none, except for Cachetastic::Adapters::File and Cachetastic::Adapters::Redis, which default to :yaml\nconfigatron.cachetastic.defaults.marshall_method = :none\nconfigatron.cachetastic.defaults.marshall_method = :yaml\nconfigatron.cachetastic.defaults.marshall_method = :ruby\n\n# This sets how long objects will live in the cache before they are auto expired.\nconfigatron.cachetastic.defaults.default_expiry = 86400 # time in seconds (default: 24 hours)\n\n# When saving objects into the cache the expiry_swing is +/- to the expiry time.\n# Example: if the expiry time is 1 minute, and the swing is 15 seconds,\n# objects will go into the cache with an expiry time sometime between 45 seconds and 75 seconds.\n# The default is 0 seconds.\nconfigatron.cachetastic.defaults.expiry_swing = 15\n\n# Configure logging for the system.\n# n number of logs can be configured for a cache.\nlog_1 = Logger.new(STDOUT)\nlog_1.level = Logger::DEBUG\nlog_2 = Logger.new(\"log/cachetastic.log\")\nlog_2.level = Logger::ERROR\nconfigatron.cachetastic.defaults.logger = [log_1, log_2]\n```\n\nOverriding settings per cache is very simple. Let's take the following two caches:\n\n```ruby\nclass UserCache \u003c Cachetastic::Cache\nend\n\nclass Admin::UserCache \u003c Cachetastic::Cache\nend\n```\n\nIf we wanted to set the \u003ccode\u003eUserCache\u003c/code\u003e to use the \u003ccode\u003eCachetastic::Adapters::File\u003c/code\u003e adapter and we wanted to set the adapter for \nthe \u003ccode\u003eAdmin::UserCache\u003c/code\u003e to use \u003ccode\u003eCachetastic::Adapters::Memcached\u003c/code\u003e, we would configure them like such:\n\n```ruby\nconfigatron.cachetastic.user_cache.adapter = Cachetastic::Adapters::File\nconfigatron.cachetastic.admin.user_cache.adapter = Cachetastic::Adapters::Memcached\n```\n\nIn this scenario we have changed the adapters for each of the classes. All of the other default settings will remain intact for each of those classes. This makes it incredibly easy to just change the one parameter you need, and not have to reset them all.\n    \n## Examples:\n\n```ruby\nclass MyAwesomeCache \u003c Cachetastic::Cache\nend\n\nMyAwesomeCache.set(1, [1,2,3])\nMyAwesomeCache.get(1) # =\u003e [1,2,3]\n\nclass MyAwesomeCache \u003c Cachetastic::Cache\n  class \u003c\u003c self\n    def get(key, x, y)\n      super(key) do\n        n = x + y\n        set(key, n)\n        n\n      end\n    end\n  end\nend\n\nMyAwesomeCache.get(1, 2, 4) # =\u003e 8\nMyAwesomeCache.get(1, 4, 4) # =\u003e 8\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fcachetastic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarkbates%2Fcachetastic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarkbates%2Fcachetastic/lists"}