{"id":18522434,"url":"https://github.com/astro/remcached","last_synced_at":"2025-04-09T11:30:52.429Z","repository":{"id":657239,"uuid":"299989","full_name":"astro/remcached","owner":"astro","description":"Ruby EventMachine memcached client","archived":false,"fork":false,"pushed_at":"2017-08-31T20:48:09.000Z","size":42,"stargazers_count":50,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T04:51:40.917Z","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/astro.png","metadata":{"files":{"readme":"README.rst","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}},"created_at":"2009-09-07T13:57:23.000Z","updated_at":"2021-01-13T19:27:06.000Z","dependencies_parsed_at":"2022-07-05T06:31:46.041Z","dependency_job_id":null,"html_url":"https://github.com/astro/remcached","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/astro%2Fremcached","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fremcached/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fremcached/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/astro%2Fremcached/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/astro","download_url":"https://codeload.github.com/astro/remcached/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247892910,"owners_count":21013804,"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-06T17:30:52.787Z","updated_at":"2025-04-09T11:30:52.056Z","avatar_url":"https://github.com/astro.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"remcached\n=========\n\n* **Ruby EventMachine memCACHED client implementation**\n* provides a direct interface to the memcached protocol and its\n  semantics\n* uses the memcached `binary protocol`_ to reduce parsing overhead on\n  the server side (requires memcached \u003e= 1.3)\n* supports multiple servers with simple round-robin key hashing\n  (**TODO:** implement the libketama algorithm) in a fault-tolerant\n  way\n* writing your own abstraction layer is recommended\n* uses RSpec\n* partially documented in RDoc-style\n\n\nCallbacks\n---------\n\nEach request `may` be passed a callback. These are not two-cased\n(success \u0026 failure) EM deferrables, but standard Ruby callbacks. The\nrationale behind this is that there are no usual success/failure\nresponses, but you will want to evaluate a ``response[:status]``\nyourself to check for cache miss, version conflict, network\ndisconnects etc.\n\nA callback may be kept if it returns ``:proceed`` to catch\nmulti-response commands such as ``STAT``.\n\nremcached has been built with **fault tolerance** in mind: a callback\nwill be called with just ``{:status =\u003e Memcached::Errors::DISCONNECTED}``\nif the network connection has went away. Thus, you can expect your\ncallback will be called, except of course you're using `quiet`\ncommands. In that case, only a \"non-usual response\" from the server or\na network failure will invoke your block.\n\n\nMulti commands\n--------------\n\nThe technique is described in the `binary protocol`_ spec in section\n**4.2**. ``Memcached.multi_operation`` will help you exactly with\nthat, sending lots of those `quiet` commands, except for the last,\nwhich will be a `normal` command to trigger an acknowledge for all\ncommands.\n\nThis is of course implemented per-server to accomodate\nload-balancing.\n\n\nUsage\n-----\n\nFirst, pass your memcached servers to the library::\n\n    Memcached.servers = %w(localhost localhost:11212 localhost:11213)\n\nNote that it won't be connected immediately. Use ``Memcached.usable?``\nto check. This however complicates your own code and you can check\n``response[:status] == Memcached::Errors::DISCONNECTED`` for network\nerrors in all your response callbacks.\n\nFurther usage is pretty straight-forward::\n\n    Memcached.get(:key =\u003e 'Hello') do |response|\n      case response[:status]\n        when Memcached::Errors::NO_ERROR\n          use_cached_value response[:value] # ...\n        when Memcached::Errors::KEY_NOT_FOUND\n          refresh_cache! # ...\n        when Memcached::Errors::DISCONNECTED\n          proceed_uncached # ...\n        else\n          cry_for_help # ...\n        end\n      end\n    end\n    Memcached.set(:key =\u003e 'Hello', :value =\u003e 'World',\n                  :expiration =\u003e 600) do |response|\n      case response[:status]\n        when Memcached::Errors::NO_ERROR\n          # That's good\n        when Memcached::Errors::DISCONNECTED\n\t  # Maybe stop filling the cache for now?\n        else\n          # What could've gone wrong?\n        end\n      end\n    end\n\nMulti-commands may require a bit of precaution::\n\n    Memcached.multi_get([{:key =\u003e 'foo'},\n                         {:key =\u003e 'bar'}]) do |responses|\n      # responses is now a hash of Key =\u003e Response\n    end\n\nIt's not guaranteed that any of these keys will be present in the\nresponse. Moreover, they may be present even if they are a usual\nresponse because the last request is always non-quiet.\n\n\n**HAPPY CACHING!**\n\n.. _binary protocol: http://code.google.com/p/memcached/wiki/MemcacheBinaryProtocol\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fremcached","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fastro%2Fremcached","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fastro%2Fremcached/lists"}