redis-proto.cr

A handy Redis storage with Protobuf objects for Crystal

redis-proto.cr Build Status

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

  1. Fork it ( https://github.com/maiha/redis-proto.cr/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • maiha maiha - creator, maintainer
Owner
github statistic
  • 1
  • 0
  • 0
  • 0
  • about 2 years ago
  • September 24, 2017
License

MIT License

Links
Synced at

Sun, 25 Oct 2020 14:01:15 GMT