{"id":13508934,"url":"https://github.com/dantswain/yar","last_synced_at":"2025-04-09T18:13:58.630Z","repository":{"id":24611154,"uuid":"28019915","full_name":"dantswain/yar","owner":"dantswain","description":"Yet another Redis client for Elixir","archived":false,"fork":false,"pushed_at":"2015-01-18T23:50:51.000Z","size":208,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T20:21:42.218Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/dantswain.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":"2014-12-15T04:06:12.000Z","updated_at":"2016-03-29T13:41:30.000Z","dependencies_parsed_at":"2022-08-22T12:00:45.700Z","dependency_job_id":null,"html_url":"https://github.com/dantswain/yar","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantswain%2Fyar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantswain%2Fyar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantswain%2Fyar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantswain%2Fyar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantswain","download_url":"https://codeload.github.com/dantswain/yar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994106,"owners_count":21030049,"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-08-01T02:01:00.661Z","updated_at":"2025-04-09T18:13:58.605Z","avatar_url":"https://github.com/dantswain.png","language":"Elixir","funding_links":[],"categories":["ORM and Datamapping"],"sub_categories":[],"readme":"YAR\n===\n\nYet Another Redis client for Elixir\n\nYAR is a [Redis](http://redis.io) client written in Elixir.  It is\nnot a wrapper around the excellent Erlang client\n[eredis](https://github.com/wooga/eredis), it is implemented\nfrom scratch in Elixir using\n[elixir-socket](https://github.com/meh/elixir-socket)\n(which is itself a wrapper around Erlang's `gen_tcp`)\nfor TCP/IP communication.\n\nThis project is probably not ready for production, though I would\ngreatly appreciate any feedback and bug reports.\n\nIf you are looking for a solid Elixir Redis client,\ncheck out [exredis](https://github.com/artemeff/exredis).\nexredis is a wrapper around [eredis](https://github.com/wooga/eredis),\nwhich is an Erlang Redis client that has been around for quite\nsome time.\n\n##Usage\n\nCreate a new Redis connection process with `YAR.connect/2` and then\nuse `YAR.execute/2` to execute raw Redis commands.\n\n```elixir\n{:ok, redis} = YAR.connect(\"localhost\", 6379)\n\"PONG\" = YAR.execute(redis, \"PING\")\n\"OK\" = YAR.execute(redis, \"SET FOO 1\")\n2 = YAR.execute(redis, \"INCR FOO\")\n\"2\" = YAR.execute(redis, \"GET FOO\")\n\"OK\" = YAR.execute(redis, \"SET BAR BAZ\")\n\"OK\" = YAR.execute(redis, [\"SET\", \"BAR\", \"BAZ\"])\n[\"2\", \"BAZ\"] = YAR.execute(redis, \"MGET FOO BAR\")\n{:error, \"unknown command 'SUP'\"} = YAR.execute(redis, \"SUP\")\n```\n\n`YAR.connect/2` takes host and port as arguments, with\ndefault values of \"localhost\" and 6379. `{:ok, redis} = Yar.connect` \nshould connect to a default local instance of redis-server on most\ninstallations.  Multiple connections can be made by simply\ncalling `Yar.connect/2` multiple times.\n\nIn theory, YAR supports arbitrary Redis commands via\n`YAR.execute/2`.  All of the basic return types should be\nsupported.\n\n`YAR.execute/2` is synchronous.  The underlying connection uses\n[elixir-socket](https://github.com/meh/elixir-socket) and stores\nthe connection information in a GenServer.\n\nThe list form of execute should be favored for performance reasons.\nThat is, `YAR.execute(redis, [\"GET\", \"FOO\"])` is slightly more\nperformant than `YAR.execute(redis, \"GET FOO\")`.\n\n##Helpers\n\nYAR has built-in helpers for some Redis commands.\n\n```elixir\n\"OK\" == YAR.set(c, \"foo\", \"bar\")\n\"bar\" == YAR.get(c, \"foo\")\n# note keys/values are interleaved\n\"OK\" == YAR.mset(c, [\"foo\", 1, \"bar\", 2])\n[\"1\", \"2\"] == YAR.mget(c, [\"foo\"], [\"bar\"])\n```\n\n##Pipelining\n\nYAR supports simple [Redis pipelining](http://redis.io/topics/pipelining)\nvia `YAR.pipeline/2`.  The second argument\nis a list of commands.  The responses are returned as a list in order\ncorresponding to the commands.\n\n```elixir\n[\"OK\", \"PING\"] == YAR.pipeline(redis, [[\"SET\", \"FOO\", \"42\"], [\"PING\"]])\n[\"42\", \"OK\"] == YAR.pipeline(redis, [[\"GET\", \"FOO\"], [\"SET\", \"FOO\", \"1\"]])\n```\n\n##Pubsub\n\nYAR supports simple [Redis subscribing](http://redis.io/topics/pubsub)\nvia `YAR.subscribe/4`.  The first argument is a pid to receive\nmessages, the second argument is a list of routing keys, the\nthird and fourth arguments are the Redis host and port, respectively\n(default \"localhost\" and 5379).  Messages are delivered as tuples\nwhere the first element is `:yarsub` and the second argument is\nthe message string.\n\n```elixir\n{:ok, subscriber_pid} = YAR.subscribe(self, [\"foo\"])\nYAR.execute(redis, [\"PUBLISH\", \"foo\", \"hullo\"])\nflush # =\u003e {:yarsub, \"hullo\"}\n```\n\n##Testing\n\nLaunch a Redis server instance on port 5000 (`redis-server -- port 5000`)\nthen run `mix test`.\n\n*CAUTION* - The test executes `FLUSHALL` between test cases. DO NOT\ntest on a production server!  If you must, take care that no\ndata is kept on a Redis instance on port 5000, or change the test port\nin `test/yar_test.exs`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantswain%2Fyar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantswain%2Fyar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantswain%2Fyar/lists"}