README.md in kredis-1.1.0 vs README.md in kredis-1.2.0
- old
+ new
@@ -107,12 +107,14 @@
enum = Kredis.enum "myenum", values: %w[ one two three ], default: "one"
"one" == enum.value # => GET myenum
true == enum.one? # => GET myenum
enum.value = "two" # => SET myenum "two"
"two" == enum.value # => GET myenum
+enum.three! # => SET myenum "three"
+"three" == enum.value # => GET myenum
enum.value = "four"
-"two" == enum.value # => GET myenum
+"three" == enum.value # => GET myenum
enum.reset # => DEL myenum
"one" == enum.value # => GET myenum
slots = Kredis.slots "myslots", available: 3
true == slots.available? # => GET myslots
@@ -166,14 +168,20 @@
You can use all these structures in models:
```ruby
class Person < ApplicationRecord
kredis_list :names
- kredis_list :names_with_custom_key, key: ->(p) { "person:#{p.id}:names_customized" }
+ kredis_list :names_with_custom_key_via_lambda, key: ->(p) { "person:#{p.id}:names_customized" }
+ kredis_list :names_with_custom_key_via_method, key: :generate_names_key
kredis_unique_list :skills, limit: 2
kredis_enum :morning, values: %w[ bright blue black ], default: "bright"
kredis_counter :steps, expires_in: 1.hour
+
+ private
+ def generate_names_key
+ "key-generated-from-private-method"
+ end
end
person = Person.find(5)
person.names.append "David", "Heinemeier", "Hansson" # => RPUSH people:5:names "David" "Heinemeier" "Hansson"
true == person.morning.bright? # => GET people:5:morning
@@ -193,16 +201,19 @@
end
```
## Installation
-1. Add the `kredis` gem to your Gemfile: `gem 'kredis'`
-2. Run `./bin/bundle install`
-3. Run `./bin/rails kredis:install` to add a default configuration at [`config/redis/shared.yml`](lib/install/shared.yml)
+1. Run `./bin/bundle add kredis`
+2. Run `./bin/rails kredis:install` to add a default configuration at [`config/redis/shared.yml`](lib/install/shared.yml)
Additional configurations can be added under `config/redis/*.yml` and referenced when a type is created. For example, `Kredis.string("mystring", config: :strings)` would lookup `config/redis/strings.yml`.
Kredis passes the configuration to `Redis.new` to establish the connection. See the [Redis documentation](https://github.com/redis/redis-rb) for other configuration options.
+
+### Redis support
+
+Kredis works with Redis server 4.0+, with the [Redis Ruby](https://github.com/redis/redis-rb) client version 4.2+.
### Setting SSL options on Redis Connections
If you need to connect to Redis with SSL, the recommended approach is to set your Redis instance manually by adding an entry to the `Kredis::Connections.connections` hash. Below an example showing how to connect to Redis using Client Authentication: