{"id":21939189,"url":"https://github.com/grottopress/dude","last_synced_at":"2026-05-03T09:33:39.975Z","repository":{"id":85787934,"uuid":"567862569","full_name":"GrottoPress/dude","owner":"GrottoPress","description":"A dead simple Redis cache","archived":false,"fork":false,"pushed_at":"2024-08-13T16:15:48.000Z","size":55,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-01-27T14:49:06.921Z","etag":null,"topics":["crystal","redis","redis-cache"],"latest_commit_sha":null,"homepage":"","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/GrottoPress.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-11-18T19:01:20.000Z","updated_at":"2024-08-13T16:15:52.000Z","dependencies_parsed_at":"2023-03-04T14:00:21.908Z","dependency_job_id":"672dcab5-b3cf-4afb-a082-2e432249b685","html_url":"https://github.com/GrottoPress/dude","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Fdude","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Fdude/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Fdude/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GrottoPress%2Fdude/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GrottoPress","download_url":"https://codeload.github.com/GrottoPress/dude/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244973695,"owners_count":20541022,"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","redis-cache"],"created_at":"2024-11-29T02:17:18.951Z","updated_at":"2026-05-03T09:33:39.970Z","avatar_url":"https://github.com/GrottoPress.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dude\n\n**Dude** is a dead simple Redis cache that supports multiple storage backends.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     dude:\n       github: GrottoPress/dude\n     #redis: # Uncomment if using the Redis backend\n     #  github: jgaskins/redis\n     #pg: # Uncomment if using the Posgres backend\n     #  github: will/crystal-pg\n   ```\n\n1. Run `shards update`\n\n1. Require and configure *Dude*:\n\n   - Using the Redis backend\n\n     ```crystal\n     # -\u003e\u003e\u003e src/app/config.cr\n\n     # ...\n\n     require \"dude/redis\"\n\n     Dude.configure do |settings|\n       settings.store = Dude::Redis.new(ENV[\"REDIS_URL\"], namespace: \"dude\")\n     end\n\n     # ...\n     ```\n\n   - Using the Postgres backend\n\n     ```crystal\n     # -\u003e\u003e\u003e src/app/config.cr\n\n     # ...\n\n     require \"dude/postgres\"\n\n     Dude.configure do |settings|\n       # ...\n       settings.store = Dude::Postgres.new(ENV[\"DATABASE_URL\"], namespace: \"dude\")\n       # OR pass an existing `DB::Database` instance\n       #settings.store = Dude::Postgres.new(db, namespace: \"dude\")\n       # ...\n     end\n\n     # You may use this in your app's migrations to migrate\n     Dude.postgres.migrate_database\n\n     # You may use this in your app's migrations to roll back\n     #Dude.postgres.rollback_database\n\n     # ...\n     ```\n\n   - Using the Memory backend\n\n     ```crystal\n     # -\u003e\u003e\u003e src/app/config.cr\n\n     # ...\n\n     require \"dude\"\n\n     Dude.configure do |settings|\n       settings.store = Dude::Memory.new\n     end\n\n     # ...\n     ```\n\n   - Skip caching\n\n     You may disable cache altogether by setting `Dude.settings.store` to `nil` (This is the default).\n\n\n## Usage\n\n- Fetch raw value from cache\n\n  ```crystal\n  # Sets and returns block if key not found in cache\n  Dude.get(\"key\", 1.minute) { \"value\" } # =\u003e `value`\n  ```\n\n- Fetch JSON-serializable value from cache\n\n  ```crystal\n  struct User\n    include JSON::Serializable\n\n    getter id : Int32\n\n    def initialize(@id)\n    end\n  end\n\n  # Sets and returns block if key not found in cache\n  Dude.get(User, \"key\", 1.minute) { User.new(2) } # =\u003e `User(@id=2)`\n  ```\n\n- Perform multiple operations using a transaction\n\n  ```crystal\n  Dude.transaction do |store|\n    Dude.set(\"key_1\", \"value1\", 1.minute, store)\n    Dude.set(\"key_2\", \"value2\", 3.minutes, store)\n    Dude.delete(\"key_3\", store)\n  end\n  ```\n\n## Development\n\nCreate a `.env.sh` file:\n\n```bash\n#!/usr/bin/env bash\n\nexport COCKROACH_URL='postgres://root@localhost:26257/dude_spec?sslmode=disable'\nexport POSTGRES_URL='postgres://postgres:password@localhost:5432/dude_spec'\nexport REDIS_URL='redis://localhost:6379/0'\n```\n\nUpdate the file with your own details. Then run tests with `source .env.sh \u0026\u0026 crystal spec`.\n\n## Contributing\n\n1. [Fork it](https://github.com/GrottoPress/dude/fork)\n1. Switch to the `master` branch: `git checkout master`\n1. Create your feature branch: `git checkout -b my-new-feature`\n1. Make your changes, updating changelog and documentation as appropriate.\n1. Commit your changes: `git commit`\n1. Push to the branch: `git push origin my-new-feature`\n1. Submit a new *Pull Request* against the `GrottoPress:master` branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrottopress%2Fdude","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrottopress%2Fdude","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrottopress%2Fdude/lists"}