redis-proto.cr
A handy Redis storage with Protobuf objects for Crystal.
storage = RedisProto(User).new("redis://", prefix: "users/", primary: "id")
storage.set(user)
storage.get("maiha")
- crystal-0.26.1
Installation
Add this to your application's shard.yml
:
dependencies:
redis-proto:
github: maiha/redis-proto.cr
version: 0.1.1
Usage
Assumed that you have Foo
class of Protobuf::Message.
require "redis-proto"
storage = RedisProto(Foo).new("redis://", prefix: "foo/", primary: "id")
foo = Foo.new(id: "a", name: "xyz")
storage.set(foo)
% redis-cli get foo/a
"\n\u{1}a\u{12}\u{3}xyz"
bar = storage.get("a")
bar.id # => "a"
bar.name # => "xyz"
storage.get?("XXX") # => nil
Development
TODO Write development instructions here
Contributing
- Fork it ( https://github.com/maiha/redis-proto.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- maiha maiha - creator, maintainer