{"id":15588508,"url":"https://github.com/hopsoft/coin","last_synced_at":"2025-10-08T01:29:59.037Z","repository":{"id":5628846,"uuid":"6836938","full_name":"hopsoft/coin","owner":"hopsoft","description":"An absurdly simple DRb based in-memory cache","archived":false,"fork":false,"pushed_at":"2018-07-22T02:12:00.000Z","size":69,"stargazers_count":13,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T12:05:37.198Z","etag":null,"topics":["cache","drb","ruby"],"latest_commit_sha":null,"homepage":"","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/hopsoft.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":"2012-11-24T06:10:54.000Z","updated_at":"2022-12-24T18:49:47.000Z","dependencies_parsed_at":"2022-07-07T11:04:52.619Z","dependency_job_id":null,"html_url":"https://github.com/hopsoft/coin","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopsoft%2Fcoin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopsoft%2Fcoin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopsoft%2Fcoin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hopsoft%2Fcoin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hopsoft","download_url":"https://codeload.github.com/hopsoft/coin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250566457,"owners_count":21451231,"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","drb","ruby"],"created_at":"2024-10-02T22:40:30.872Z","updated_at":"2025-10-08T01:29:54.020Z","avatar_url":"https://github.com/hopsoft.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Lines of Code](http://img.shields.io/badge/lines_of_code-186-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)\n[![Maintainability](https://api.codeclimate.com/v1/badges/ef8ed3f1eca8c3e5509f/maintainability)](https://codeclimate.com/github/hopsoft/coin/maintainability)\n[![Build Status](http://img.shields.io/travis/hopsoft/coin.svg?style=flat)](https://travis-ci.org/hopsoft/coin)\n[![Coverage Status](https://img.shields.io/coveralls/hopsoft/coin.svg?style=flat)](https://coveralls.io/r/hopsoft/coin?branch=master)\n[![Downloads](http://img.shields.io/gem/dt/coin.svg?style=flat)](http://rubygems.org/gems/coin)\n\n# Coin\n\n## Memcached? We don't need no stinking Memcached. \u003csup\u003e\u003ca href=\"#cultural-references\"\u003e1\u003c/a\u003e\u003c/sup\u003e\n\nWell... you might depending upon your specific needs,\nbut have a look at Coin before you reach for the sledgehammer.\n\nCoin is an absurdly simple in memory object caching system written in Ruby.\n\n## Why Coin?\n\n* No configuration required\n* No added complexity to your stack\n* Small footprint (under 200 lines)\n* Simple API\n\nCoin uses [Distributed Ruby (DRb)](http://pragprog.com/book/sidruby/the-druby-book)\nto create a simple in memory caching server that addresses many of the same needs as Memcached\nand other similar solutions.\n\n## Quick Start\n\nInstallation\n\n```bash\n$ gem install coin\n```\n\nBasic Usage\n\n```ruby\nrequire \"coin\"\nCoin.write :foo, true\nCoin.read :foo # =\u003e true\n```\n\n## Next Steps\n\nExamples of more advanced usage.\n\n```ruby\nrequire \"coin\"\n\n# read and/or assign a default value in a single atomic step\nCoin.read(:bar) { true } # =\u003e true\n\n# write data with an explicit expiration (in seconds)\n# this example expires in 5 seconds (default is 300)\nCoin.write :bar, true, 5\nsleep 5\nCoin.read :bar # =\u003e nil\n\n# delete an entry\nCoin.write :bar, true\nCoin.delete :bar\nCoin.read :bar # =\u003e nil\n\n# read and delete in a single atomic step\nCoin.write :bar, true\nCoin.read_and_delete :bar # =\u003e true\nCoin.read :bar # =\u003e nil\n\n# read and update in a single atomic step\nCoin.write :bar, true\nCoin.read_and_update :bar do |value|\n  !value\nend\nCoin.read :bar # =\u003e false\n\n# determine how many items are in the cache\n10.times do |i|\n  Coin.write \"key#{i}\", true\nend\nCoin.length # =\u003e 10\n\n# clear the cache\nCoin.clear\nCoin.length # =\u003e 0\n```\n\n## Deep Cuts\n\nCoin automatically starts a DRb server that hosts the Coin::Vault.\nYou can take control of this behavior if needed.\n\n```ruby\nrequire \"coin\"\n\n# configure the port that the DRb server runs on (default is 8955)\nCoin.port = 8080\n\n# configure the URI that the DRb server runs on (defaults to druby://localhost:PORT)\nCoin.uri = \"druby://10.0.0.100:8080\"\n\n# access the DRb server exposing Coin::Vault\nCoin.server # =\u003e #\u003cCoin::Vault:0x007fe182852e18\u003e\n\n# determine if the server is running\nCoin.server_running? # =\u003e true\n\n# determine the pid of the server process\nCoin.pid # =\u003e \"63299\"\n\n# stop the server\nCoin.stop_server # =\u003e true\n\n# start the server\nCoin.start_server # =\u003e true\n\n# start the server forcing a restart if the server is already running\nCoin.start_server true # =\u003e true\n```\n\nCoin also supports configuring a remote server.\nAllowing a single Coin server to service multiple machines.\n\n```ruby\nCoin.remote_uri = \"druby://192.168.0.12:8808\"\n```\n\nWant interoperability with other languages? Check out\n[CoinRack](https://github.com/hopsoft/coin_rack) which provides\na REST API on top of Coin.\n\n## Best Practices\n\nAll objects stored with Coin must be able to marshal.\n\nIts generally a good idea to store only the most basic objects.\nFor example:\n\n* Boolean\n* String\n* Number\n\nIts possible to store more complex objects such as:\n\n* Array\n* Hash\n\nJust be sure to limit the keys \u0026 values to basic types.\n\n## Run the Tests\n\n```bash\n$ gem install coin\n$ gem unpack coin\n$ cd coin-VERSION\n$ bundle\n$ mt\n```\n\n## Notes\n\nCoin's default behavior launches a single DRb server that provides\nshared access across all processes on a **single machine**.\nYou need to configure `Coin.remote_uri` if you want Coin to connect to a\nDRb server on another machine.\n\n![Coin Diagram](https://raw.github.com/hopsoft/coin/gh-pages/assets/images/coin.png)\n\n## Cultural References\n\n1. \"Badges? We don't need no stinking badges!\" - from Mel Brooks' film [Blazing Saddles](http://en.wikipedia.org/wiki/Stinking_badges)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopsoft%2Fcoin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhopsoft%2Fcoin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhopsoft%2Fcoin/lists"}