kredis 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of kredis might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6977b6ccbe9dba3574b4f0fe0c107fde3e1ff8a4e8a52f46076fe8df3acab2db
4
- data.tar.gz: b3b9fb9c0e82a898168c6a9442cba36938bc4f7b9046dca16be052d28074c3ef
3
+ metadata.gz: c1cd3c7afcd05236cdb9ed3980d0969077f594da2fe1ca0be383610be4a4b37c
4
+ data.tar.gz: 912cd1ed2ff7d0b05df1fcacb07e0272ba098b86645a0607a80aa69e65107223
5
5
  SHA512:
6
- metadata.gz: aa0715d6e188a7261f2f4c27f13a1b4dc919c5bf339c29435836693c3ae8df19f63ae54ff0d0ca28712f984a238df124bdc06ab268b85c88fd28179ae1534560
7
- data.tar.gz: 9bb31956f1c666e64fc50c12a35b1a9ebefad8ec7f139b67c73033e745c48b8f271736b533c91eb6a4c84a892f541edb634688663219bd1285a1c3aafb996efd
6
+ metadata.gz: 8d7fa6004370d1d75c8b2567397ab88d65351af3d42d381cfc602d3db2a12eb10cdf0e42d190c802dea9d02fee112130cd6786ef60a125581924d82630191ebc
7
+ data.tar.gz: '07286763861b342cb8dd67c55f1df2e84d2496aa41a626bf23bd186ab7b8c698018cc7cb42bf65128cfb2a88eb22a9f73c84fa8a8a0516aaedb56d8c18624b19'
data/README.md CHANGED
@@ -105,24 +105,24 @@ cycle.next # => GET mycycle + SET mycycle 0
105
105
  :one == cycle.value # => GET mycycle
106
106
 
107
107
  enum = Kredis.enum "myenum", values: %w[ one two three ], default: "one"
108
- "one" == enum.value # => GET myenum
108
+ "one" == enum.value # => GET myenum
109
109
  true == enum.one? # => GET myenum
110
110
  enum.value = "two" # => SET myenum "two"
111
111
  "two" == enum.value # => GET myenum
112
112
  enum.value = "four"
113
113
  "two" == enum.value # => GET myenum
114
114
  enum.reset # => DEL myenum
115
- "one" == enum.value # => GET myenum
115
+ "one" == enum.value # => GET myenum
116
116
 
117
117
  slots = Kredis.slots "myslots", available: 3
118
118
  true == slots.available? # => GET myslots
119
119
  slots.reserve # => INCR myslots
120
120
  true == slots.available? # => GET myslots
121
- slots.reserve # => INCR myslots
121
+ slots.reserve # => INCR myslots
122
122
  true == slots.available? # => GET myslots
123
123
  slots.reserve # => INCR myslots
124
124
  false == slots.available? # => GET myslots
125
- slots.reserve # => INCR myslots + DECR myslots
125
+ slots.reserve # => INCR myslots + DECR myslots
126
126
  false == slots.available? # => GET myslots
127
127
  slots.release # => DECR myslots
128
128
  true == slots.available? # => GET myslots
@@ -141,7 +141,7 @@ flag = Kredis.flag "myflag"
141
141
  false == flag.marked? # => EXISTS myflag
142
142
  flag.mark # => SET myflag 1
143
143
  true == flag.marked? # => EXISTS myflag
144
- flag.remove # => DEL myflag
144
+ flag.remove # => DEL myflag
145
145
  false == flag.marked? # => EXISTS myflag
146
146
 
147
147
  true == flag.mark(expires_in: 1.second, force: false) #=> SET myflag 1 EX 1 NX
@@ -196,26 +196,11 @@ end
196
196
 
197
197
  1. Add the `kredis` gem to your Gemfile: `gem 'kredis'`
198
198
  2. Run `./bin/bundle install`
199
- 3. Add a default configuration under `config/redis/shared.yml`
200
-
201
- A default configuration can look like this for `config/redis/shared.yml`:
202
-
203
- ```yaml
204
- production: &production
205
- host: <%= ENV.fetch("REDIS_SHARED_HOST", "127.0.0.1") %>
206
- port: <%= ENV.fetch("REDIS_SHARED_PORT", "6379") %>
207
- timeout: 1
199
+ 3. Run `./bin/rails kredis:install` to add a default configuration at [`config/redis/shared.yml`](lib/install/shared.yml)
208
200
 
209
- development: &development
210
- host: <%= ENV.fetch("REDIS_SHARED_HOST", "127.0.0.1") %>
211
- port: <%= ENV.fetch("REDIS_SHARED_PORT", "6379") %>
212
- timeout: 1
213
-
214
- test:
215
- <<: *development
216
- ```
201
+ 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`.
217
202
 
218
- Additional configurations can be added under `config/redis/*.yml` and referenced when a type is created, e.g. `Kredis.string("mystring", config: :strings)` would lookup `config/redis/strings.yml`. Under the hood `Kredis.configured_for` is called which'll pass the configuration on to `Redis.new`.
203
+ 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.
219
204
 
220
205
  ### Setting SSL options on Redis Connections
221
206
 
@@ -0,0 +1,6 @@
1
+ yaml_path = Rails.root.join("config/redis/shared.yml")
2
+ unless yaml_path.exist?
3
+ say "Adding `config/redis/shared.yml`"
4
+ empty_directory yaml_path.parent.to_s
5
+ copy_file "#{__dir__}/shared.yml", yaml_path
6
+ end
@@ -0,0 +1,15 @@
1
+ production: &production
2
+ url: <%= ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379/0") %>
3
+ timeout: 1
4
+
5
+ development: &development
6
+ url: <%= ENV.fetch("REDIS_URL", "redis://127.0.0.1:6379/0") %>
7
+ timeout: 1
8
+
9
+ # You can also specify host, port, and db instead of url
10
+ # host: <%= ENV.fetch("REDIS_SHARED_HOST", "127.0.0.1") %>
11
+ # port: <%= ENV.fetch("REDIS_SHARED_PORT", "6379") %>
12
+ # db: <%= ENV.fetch("REDIS_SHARED_DB", "11") %>
13
+
14
+ test:
15
+ <<: *development
@@ -30,4 +30,9 @@ class Kredis::Railtie < ::Rails::Railtie
30
30
  include Kredis::Attributes
31
31
  end
32
32
  end
33
+
34
+ rake_tasks do
35
+ path = File.expand_path("..", __dir__)
36
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
37
+ end
33
38
  end
@@ -7,7 +7,7 @@ class Kredis::Types::CallbacksProxy
7
7
  Kredis::Types::Cycle => %i[ next ],
8
8
  Kredis::Types::Enum => %i[ value= reset ],
9
9
  Kredis::Types::Flag => %i[ mark remove ],
10
- Kredis::Types::Hash => %i[ update delete ],
10
+ Kredis::Types::Hash => %i[ update delete []= remove ],
11
11
  Kredis::Types::List => %i[ remove prepend append << ],
12
12
  Kredis::Types::Scalar => %i[ value= clear ],
13
13
  Kredis::Types::Set => %i[ add << remove replace take clear ],
@@ -16,7 +16,7 @@ class Kredis::Types::UniqueList < Kredis::Types::List
16
16
  multi do
17
17
  remove elements
18
18
  super
19
- ltrim (limit - 1), -1 if limit
19
+ ltrim -limit, -1 if limit
20
20
  end if Array(elements).flatten.any?
21
21
  end
22
22
  alias << append
@@ -1,3 +1,3 @@
1
1
  module Kredis
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -0,0 +1,6 @@
1
+ namespace :kredis do
2
+ desc "Install kredis"
3
+ task :install do
4
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{File.expand_path("../../install/install.rb", __dir__)}"
5
+ end
6
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kredis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Timm Hansen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-11-22 00:00:00.000000000 Z
12
+ date: 2021-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -61,6 +61,8 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - MIT-LICENSE
63
63
  - README.md
64
+ - lib/install/install.rb
65
+ - lib/install/shared.yml
64
66
  - lib/kredis.rb
65
67
  - lib/kredis/attributes.rb
66
68
  - lib/kredis/connections.rb
@@ -87,6 +89,7 @@ files:
87
89
  - lib/kredis/types/slots.rb
88
90
  - lib/kredis/types/unique_list.rb
89
91
  - lib/kredis/version.rb
92
+ - lib/tasks/kredis/install.rake
90
93
  homepage: https://github.com/rails/kredis
91
94
  licenses:
92
95
  - MIT
@@ -106,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
109
  - !ruby/object:Gem::Version
107
110
  version: '0'
108
111
  requirements: []
109
- rubygems_version: 3.2.22
112
+ rubygems_version: 3.2.30
110
113
  signing_key:
111
114
  specification_version: 4
112
115
  summary: Higher-level data structures built on Redis.