{"id":17681041,"url":"https://github.com/vladfaust/mini_redis","last_synced_at":"2025-04-20T18:33:04.150Z","repository":{"id":94995853,"uuid":"167797234","full_name":"vladfaust/mini_redis","owner":"vladfaust","description":"A light-weight low-level Redis client for Crystal ♨️","archived":false,"fork":false,"pushed_at":"2019-08-21T20:07:25.000Z","size":156,"stargazers_count":17,"open_issues_count":8,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-02T13:42:06.339Z","etag":null,"topics":["crystal","redis"],"latest_commit_sha":null,"homepage":"https://github.vladfaust.com/mini_redis","language":"Crystal","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/vladfaust.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-27T10:41:07.000Z","updated_at":"2024-03-09T22:08:09.000Z","dependencies_parsed_at":"2023-03-13T16:54:38.680Z","dependency_job_id":null,"html_url":"https://github.com/vladfaust/mini_redis","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladfaust%2Fmini_redis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladfaust%2Fmini_redis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladfaust%2Fmini_redis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vladfaust%2Fmini_redis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vladfaust","download_url":"https://codeload.github.com/vladfaust/mini_redis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223835370,"owners_count":17211158,"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":["crystal","redis"],"created_at":"2024-10-24T09:10:01.558Z","updated_at":"2024-11-09T14:04:06.550Z","avatar_url":"https://github.com/vladfaust.png","language":"Crystal","funding_links":["https://www.patreon.com/vladfaust"],"categories":[],"sub_categories":[],"readme":"# MiniRedis\n\n[![Built with Crystal](https://img.shields.io/badge/built%20with-crystal-000000.svg?style=flat-square)](https://crystal-lang.org/)\n[![Build status](https://img.shields.io/travis/com/vladfaust/mini_redis/master.svg?style=flat-square)](https://travis-ci.com/vladfaust/mini_redis)\n[![API Docs](https://img.shields.io/badge/api_docs-online-brightgreen.svg?style=flat-square)](https://github.vladfaust.com/mini_redis)\n[![Releases](https://img.shields.io/github/release/vladfaust/mini_redis.svg?style=flat-square)](https://github.com/vladfaust/mini_redis/releases)\n[![Awesome](https://awesome.re/badge-flat2.svg)](https://github.com/veelenga/awesome-crystal)\n[![vladfaust.com](https://img.shields.io/badge/style-.com-lightgrey.svg?longCache=true\u0026style=flat-square\u0026label=vladfaust\u0026colorB=0a83d8)](https://vladfaust.com)\n[![Patrons count](https://img.shields.io/badge/dynamic/json.svg?label=patrons\u0026url=https://www.patreon.com/api/user/11296360\u0026query=$.included[0].attributes.patron_count\u0026style=flat-square\u0026colorB=red\u0026maxAge=86400)](https://www.patreon.com/vladfaust)\n[![Gitter chat](https://img.shields.io/badge/chat%20on-gitter-green.svg?colorB=ED1965\u0026logo=gitter\u0026style=flat-square)](https://gitter.im/vladfaust/Lobby)\n\nA light-weight Redis client for [Crystal](https://crystal-lang.org/).\n\n[![Become Patron](https://vladfaust.com/img/patreon-small.svg)](https://www.patreon.com/vladfaust)\n\n## About\n\nMiniRedis is a light-weight low-level alternative to existing Redis client implementations.\n\nIn comparison with [crystal-redis](https://github.com/stefanwille/crystal-redis), MiniRedis has lesser memory consumption, built-in logging and first-class support for raw bytes. It also doesn't need to be updated with every Redis release.\n\nOn the other hand, MiniRedis doesn't have commands API (i.e. instead of `redis.ping` you should write `redis.send(\"PING\")`). However, such a low-level interface terminates the dependency on the third-party client maintainer (i.e. me), which makes it a perfect fit to use within a shard.\n\nYou can always find the actual Redis commands API at \u003chttps://redis.io/commands\u003e.\n\n### Benchmarks\n\nBenchmarks code can be found at \u003chttps://github.com/vladfaust/mini_redis-benchmarks\u003e.\nThese are recent results of comparison MiniRedis with [crystal-redis](https://github.com/stefanwille/crystal-redis).\n\n#### `send` benchmarks\n\n```sh\n\u003e env REDIS_URL=redis://localhost:6379/1 crystal src/send.cr --release\nmini_redis     13.4k ( 74.62µs) (± 2.50%)   32 B/op        fastest\ncrystal-redis  13.36k ( 74.83µs) (± 2.97%)  144 B/op   1.00× slower\n```\n\n**Conclusion:** `mini_redis` is more memory-efficient.\n\n#### Pipeline mode benchmarks\n\n1 million pipelined `send`s, average from 30 times repeats:\n\n```sh\n\u003e env REDIS_URL=redis://localhost:6379/1 crystal src/pipeline.cr --release\nmini_redis    914.569ms 1.093M ops/s\ncrystal-redis 908.182ms 1.101M ops/s\n```\n\n**Conclusion:** `mini_redis` has almost the same speed as `crystal-redis`.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n```yaml\ndependencies:\n  mini_redis:\n    github: vladfaust/mini_redis\n    version: ~\u003e 0.2.0\n```\n\n2. Run `shards install`\n\nThis shard follows [Semantic Versioning v2.0.0](http://semver.org/), so check [releases](https://github.com/vladfaust/timer.cr/releases) and change the `version` accordingly. Note that until Crystal is officially released, this shard would be in beta state (`0.*.*`), with every **minor** release considered breaking. For example, `0.1.0` → `0.2.0` is breaking and `0.1.0` → `0.1.1` is not.\n\n## Usage\n\n```crystal\nrequire \"mini_redis\"\n\nredis = MiniRedis.new\n\n# MiniRedis responses wrap `Int64 | String | Bytes | Nil | Array(Value)` values,\n# which map to `Integer`, `Simple String`, `Bulk String`, `Nil` and `Array` Redis values\n\n# SET command returns `Simple String`, which is `String` in Crystal\npp redis.send(\"SET\", \"foo\", \"bar\").raw.as(String) # =\u003e \"OK\"\n\n# GET command returns `Bulk String`, which is `Bytes` in Crystal\nbytes = redis.send(\"GET\", \"foo\").raw.as(Bytes)\npp String.new(bytes) # =\u003e \"bar\"\n\n# Bytes command payloads are also supported\nredis.send(\"set\", \"foo\".to_slice, \"bar\".to_slice)\n```\n\n### Pipelining\n\n```crystal\nresponse = redis.pipeline do |pipe|\n  # WARNING: Accessing the `.send` return value\n  # within the pipe block would crash the program!\n  pipe.send(\"SET\", \"foo\", \"bar\")\nend\n\npp typeof(response) # =\u003e [MiniRedis::Value(@raw=\"OK\")]\n```\n\n### Transactions\n\n```crystal\nresponse = redis.transaction do |tx|\n  pp tx.send(\"SET\", \"foo\", \"bar\").raw.as(String) # =\u003e \"QUEUED\"\nend\n\npp typeof(response) # =\u003e MiniRedis::Value(@raw=[MiniRedis::Value(@raw=\"OK\")])\n```\n\n### Connection pool\n\n```crystal\npool = MiniRedis::Pool.new\n\nresponse = pool.get do |redis|\n  # Redis is MiniRedis instance, can do anything\n  redis.send(\"PING\")\nend\n\n# Return value equals to the block's\npp response.raw.as(String) # =\u003e \"PONG\"\n\nconn = pool.get\npp conn.send(\"PING\").raw.as(String) # =\u003e \"PONG\"\npool.release(conn) # Do not forget to put it back!\n```\n\n## Development\n\n`env REDIS_URL=redis://localhost:6379 crystal spec` and you're good to go.\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/vladfaust/mini_redis/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'feat: new feature'`) using [angular-style commits](https://docs.onyxframework.org/contributing/commit-style)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Vlad Faust](https://github.com/vladfaust) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladfaust%2Fmini_redis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvladfaust%2Fmini_redis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvladfaust%2Fmini_redis/lists"}