{"id":47776859,"url":"https://github.com/luckyframework/lucky_cache_redis_store","last_synced_at":"2026-04-03T12:01:10.459Z","repository":{"id":346677449,"uuid":"1013243147","full_name":"luckyframework/lucky_cache_redis_store","owner":"luckyframework","description":"An adapter for LuckyCache to store cache in Redis","archived":false,"fork":false,"pushed_at":"2026-03-24T23:27:31.000Z","size":34,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-26T04:59:45.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/luckyframework.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-07-03T15:20:47.000Z","updated_at":"2026-03-24T23:25:30.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/luckyframework/lucky_cache_redis_store","commit_stats":null,"previous_names":["luckyframework/lucky_cache_redis_store"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/luckyframework/lucky_cache_redis_store","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyframework%2Flucky_cache_redis_store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyframework%2Flucky_cache_redis_store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyframework%2Flucky_cache_redis_store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyframework%2Flucky_cache_redis_store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luckyframework","download_url":"https://codeload.github.com/luckyframework/lucky_cache_redis_store/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luckyframework%2Flucky_cache_redis_store/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31349561,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-03T08:03:20.796Z","status":"ssl_error","status_checked_at":"2026-04-03T08:00:37.834Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-04-03T12:00:32.419Z","updated_at":"2026-04-03T12:01:10.453Z","avatar_url":"https://github.com/luckyframework.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuckyCache Redis Store\n\nA Redis storage backend for [LuckyCache](https://github.com/luckyframework/lucky_cache/), providing distributed caching capabilities for Lucky Framework applications.\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     lucky_cache_redis_store:\n       github: luckyframework/lucky_cache_redis_store\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"lucky_cache_redis_store\"\n\nLuckyCache.configure do |settings|\n  settings.storage = LuckyCache::RedisStore.new(\n    Redis::Client.new(host: \"localhost\", port: 6379),\n    prefix: \"myapp:cache:\"\n  )\n  settings.default_duration = 5.minutes\nend\n```\n\n### Basic Usage\n\n```crystal\ncache = LuckyCache.settings.storage\n\n# Write to cache\ncache.write(\"my_key\", expires_in: 1.hour) { \"my value\" }\n\n# Read from cache\nif item = cache.read(\"my_key\")\n  puts item.value # =\u003e \"my value\"\nend\n\n# Fetch (read-through cache)\nvalue = cache.fetch(\"computed_key\", as: String, expires_in: 10.minutes) do\n  # This block is only executed if the key doesn't exist\n  expensive_computation\nend\n\n# Delete from cache\ncache.delete(\"my_key\")\n\n# Clear all cached items with the configured prefix\ncache.flush\n```\n\n## Expiration Semantics\n\n- `expires_in` is stored with millisecond precision.\n- TTL values must be at least `1.millisecond`.\n- `0.seconds`, negative durations, and positive durations below `1.millisecond` raise `ArgumentError`.\n- `read` restores cache items with their original TTL metadata and the correct absolute expiration time.\n\n## Prefix Operations\n\n- `flush` removes only keys that match the store's configured prefix.\n- `size` counts only keys that match the configured prefix.\n- Both operations iterate Redis with `SCAN`, not `KEYS`, so they remain safer on larger keyspaces.\n\n### Supported Types\n\nThe Redis store supports the following types:\n- Basic types: `String`, `Int32`, `Int64`, `Float64`, `Bool`, `Time`, `UUID`, `JSON::Any`\n- Arrays of basic types: `Array(String)`, `Array(Int32)`, `Array(Int64)`, `Array(Float64)`, `Array(Bool)`\n\n**Note:** Custom objects that include `LuckyCache::Cacheable` are not supported by RedisStore due to serialization limitations. Use MemoryStore for caching custom objects.\n\n### Workaround for Custom Objects\n\nYou can cache JSON representations of your objects:\n\n```crystal\n# Instead of caching the object directly\n# cache.write(\"user:123\") { User.new(\"test@example.com\") } # This will raise an error\n\n# Cache a JSON representation\nuser_data = {\n  \"id\" =\u003e JSON::Any.new(123_i64),\n  \"email\" =\u003e JSON::Any.new(\"test@example.com\"),\n}\ncache.write(\"user:123\") { JSON::Any.new(user_data) }\n\n# Retrieve and reconstruct\ncached_data = cache.read(\"user:123\").not_nil!.value.as(JSON::Any)\nuser = User.new(cached_data[\"email\"].as_s)\n```\n\n## Development\n\nTo run the tests:\n\n1. Make sure Redis is running locally on the default port (`6379`)\n2. Run `crystal spec`\n\nThe test suite includes tests for:\n- Basic type caching\n- Array type caching\n- Millisecond TTL handling and TTL validation\n- Expiration correctness after Redis deserialization\n- Key deletion, prefix-scoped flushing, and prefix-scoped sizing\n- Standalone shard loading\n- Custom prefix support\n- Error handling for non-serializable types\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/your-github-user/lucky_cache_redis_store/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Jeremy Woertink](https://github.com/jwoertink) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckyframework%2Flucky_cache_redis_store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluckyframework%2Flucky_cache_redis_store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluckyframework%2Flucky_cache_redis_store/lists"}