rigortype 0.1.19 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +41 -6
- data/data/core_overlay/numeric.rbs +33 -0
- data/data/core_overlay/pathname.rbs +25 -0
- data/data/core_overlay/string_scanner.rbs +28 -0
- data/data/gem_overlay/activesupport/core_ext.rbs +473 -0
- data/data/vendored_gem_sigs/ast/ast.rbs +130 -0
- data/data/vendored_gem_sigs/bcrypt/bcrypt.rbs +47 -0
- data/data/vendored_gem_sigs/bundler/bundler.rbs +238 -0
- data/data/vendored_gem_sigs/cgi/cgi_extras.rbs +34 -0
- data/data/vendored_gem_sigs/did_you_mean/did_you_mean_extras.rbs +34 -0
- data/data/vendored_gem_sigs/idn-ruby/idn.rbs +54 -0
- data/data/vendored_gem_sigs/mysql2/client.rbs +55 -0
- data/data/vendored_gem_sigs/mysql2/error.rbs +5 -0
- data/data/vendored_gem_sigs/mysql2/result.rbs +31 -0
- data/data/vendored_gem_sigs/mysql2/statement.rbs +5 -0
- data/data/vendored_gem_sigs/nokogiri/nokogiri.rbs +2332 -0
- data/data/vendored_gem_sigs/nokogiri/nokogiri_html5.rbs +47 -0
- data/data/vendored_gem_sigs/pg/pg.rbs +212 -0
- data/data/vendored_gem_sigs/prism/prism_supplement.rbs +44 -0
- data/data/vendored_gem_sigs/redis/errors.rbs +50 -0
- data/data/vendored_gem_sigs/redis/future.rbs +5 -0
- data/data/vendored_gem_sigs/redis/redis.rbs +348 -0
- data/data/vendored_gem_sigs/redis/redis_extras.rbs +130 -0
- data/data/vendored_gem_sigs/rubygems/rubygems_extras.rbs +226 -0
- data/lib/rigor/analysis/check_rules/ivar_write_collector.rb +3 -23
- data/lib/rigor/analysis/check_rules/rule_walk.rb +3 -21
- data/lib/rigor/analysis/check_rules/self_closedness_scanner.rb +24 -15
- data/lib/rigor/analysis/check_rules.rb +492 -71
- data/lib/rigor/analysis/dependency_source_inference/index.rb +4 -7
- data/lib/rigor/analysis/dependency_source_inference/walker.rb +2 -18
- data/lib/rigor/analysis/dependency_source_inference.rb +3 -12
- data/lib/rigor/analysis/fact_store.rb +5 -4
- data/lib/rigor/analysis/rule_catalog.rb +153 -6
- data/lib/rigor/analysis/runner/diagnostic_aggregator.rb +17 -17
- data/lib/rigor/analysis/runner/project_pre_passes.rb +9 -8
- data/lib/rigor/analysis/runner.rb +17 -6
- data/lib/rigor/analysis/self_call_resolution_recorder.rb +3 -4
- data/lib/rigor/analysis/worker_session.rb +10 -14
- data/lib/rigor/builtins/predefined_constant_refinements.rb +151 -0
- data/lib/rigor/cache/store.rb +5 -3
- data/lib/rigor/cli/annotate_command.rb +28 -7
- data/lib/rigor/cli/baseline_command.rb +4 -3
- data/lib/rigor/cli/check_command.rb +138 -16
- data/lib/rigor/cli/coverage_command.rb +138 -31
- data/lib/rigor/cli/coverage_mutation.rb +149 -0
- data/lib/rigor/cli/coverage_scan.rb +57 -0
- data/lib/rigor/cli/explain_command.rb +2 -0
- data/lib/rigor/cli/fused_protection_renderer.rb +67 -0
- data/lib/rigor/cli/fused_protection_report.rb +76 -0
- data/lib/rigor/cli/lsp_command.rb +3 -7
- data/lib/rigor/cli/mutation_protection_renderer.rb +63 -0
- data/lib/rigor/cli/mutation_protection_report.rb +73 -0
- data/lib/rigor/cli/options.rb +9 -0
- data/lib/rigor/cli/plugins_command.rb +2 -1
- data/lib/rigor/cli/protection_renderer.rb +63 -0
- data/lib/rigor/cli/protection_report.rb +68 -0
- data/lib/rigor/cli/sig_gen_command.rb +2 -1
- data/lib/rigor/cli/trace_command.rb +2 -1
- data/lib/rigor/cli/triage_command.rb +2 -1
- data/lib/rigor/cli/type_of_command.rb +1 -1
- data/lib/rigor/cli/type_scan_command.rb +2 -1
- data/lib/rigor/cli.rb +3 -2
- data/lib/rigor/config_audit.rb +152 -0
- data/lib/rigor/configuration/dependencies.rb +2 -4
- data/lib/rigor/configuration.rb +57 -7
- data/lib/rigor/environment/bundle_sig_discovery.rb +61 -13
- data/lib/rigor/environment/class_registry.rb +4 -3
- data/lib/rigor/environment/constant_type_cache_holder.rb +43 -0
- data/lib/rigor/environment/lockfile_resolver.rb +1 -1
- data/lib/rigor/environment/rbs_collection_discovery.rb +1 -2
- data/lib/rigor/environment/rbs_coverage_report.rb +2 -1
- data/lib/rigor/environment/rbs_loader.rb +76 -5
- data/lib/rigor/environment.rb +66 -8
- data/lib/rigor/flow_contribution/fact.rb +1 -1
- data/lib/rigor/flow_contribution.rb +3 -5
- data/lib/rigor/inference/acceptance.rb +17 -9
- data/lib/rigor/inference/block_parameter_binder.rb +2 -3
- data/lib/rigor/inference/builtins/comparable_catalog.rb +2 -2
- data/lib/rigor/inference/builtins/enumerable_catalog.rb +2 -2
- data/lib/rigor/inference/builtins/method_catalog.rb +19 -0
- data/lib/rigor/inference/builtins/string_catalog.rb +9 -1
- data/lib/rigor/inference/expression_typer.rb +20 -28
- data/lib/rigor/inference/hkt_body.rb +8 -11
- data/lib/rigor/inference/hkt_body_parser.rb +10 -12
- data/lib/rigor/inference/hkt_registry.rb +10 -11
- data/lib/rigor/inference/method_dispatcher/call_context.rb +1 -4
- data/lib/rigor/inference/method_dispatcher/constant_folding.rb +169 -24
- data/lib/rigor/inference/method_dispatcher/data_folding.rb +9 -73
- data/lib/rigor/inference/method_dispatcher/file_folding.rb +6 -7
- data/lib/rigor/inference/method_dispatcher/iterator_dispatch.rb +10 -16
- data/lib/rigor/inference/method_dispatcher/kernel_dispatch.rb +25 -13
- data/lib/rigor/inference/method_dispatcher/member_shape_projection.rb +93 -0
- data/lib/rigor/inference/method_dispatcher/overload_selector.rb +1 -3
- data/lib/rigor/inference/method_dispatcher/rbs_dispatch.rb +24 -22
- data/lib/rigor/inference/method_dispatcher/shape_dispatch.rb +90 -15
- data/lib/rigor/inference/method_dispatcher/struct_folding.rb +303 -0
- data/lib/rigor/inference/method_dispatcher.rb +40 -48
- data/lib/rigor/inference/mutation_widening.rb +5 -11
- data/lib/rigor/inference/narrowing.rb +14 -16
- data/lib/rigor/inference/parameter_inference_collector.rb +367 -0
- data/lib/rigor/inference/project_patched_methods.rb +4 -7
- data/lib/rigor/inference/project_patched_scanner.rb +2 -13
- data/lib/rigor/inference/protection_scanner.rb +86 -0
- data/lib/rigor/inference/scope_indexer.rb +129 -55
- data/lib/rigor/inference/statement_evaluator.rb +271 -114
- data/lib/rigor/inference/struct_fold_safety.rb +181 -0
- data/lib/rigor/inference/synthetic_method.rb +7 -7
- data/lib/rigor/language_server/completion_provider.rb +6 -12
- data/lib/rigor/language_server/diagnostic_publisher.rb +4 -4
- data/lib/rigor/language_server/document_symbol_provider.rb +3 -3
- data/lib/rigor/language_server/hover_provider.rb +2 -3
- data/lib/rigor/language_server/hover_renderer.rb +2 -11
- data/lib/rigor/language_server/server.rb +9 -17
- data/lib/rigor/language_server.rb +4 -5
- data/lib/rigor/plugin/base.rb +10 -8
- data/lib/rigor/plugin/macro/block_as_method.rb +3 -4
- data/lib/rigor/plugin/macro/heredoc_template.rb +4 -7
- data/lib/rigor/plugin/macro/trait_registry.rb +3 -6
- data/lib/rigor/plugin/macro.rb +4 -5
- data/lib/rigor/plugin/manifest.rb +45 -66
- data/lib/rigor/plugin/registry.rb +6 -7
- data/lib/rigor/plugin/type_node_resolver.rb +6 -8
- data/lib/rigor/protection/diagnostic_oracle.rb +51 -0
- data/lib/rigor/protection/mutation_scanner.rb +180 -0
- data/lib/rigor/protection/mutator.rb +267 -0
- data/lib/rigor/protection/test_suite_oracle.rb +68 -0
- data/lib/rigor/rbs_extended.rb +24 -36
- data/lib/rigor/reflection.rb +4 -7
- data/lib/rigor/scope/discovery_index.rb +14 -2
- data/lib/rigor/scope.rb +54 -11
- data/lib/rigor/sig_gen/observed_call.rb +3 -3
- data/lib/rigor/sig_gen/writer.rb +40 -2
- data/lib/rigor/signature_path_audit.rb +92 -0
- data/lib/rigor/source/constant_path.rb +62 -0
- data/lib/rigor/source.rb +1 -0
- data/lib/rigor/type/bound_method.rb +2 -11
- data/lib/rigor/type/combinator.rb +16 -3
- data/lib/rigor/type/constant.rb +2 -11
- data/lib/rigor/type/data_class.rb +2 -11
- data/lib/rigor/type/data_instance.rb +2 -11
- data/lib/rigor/type/hash_shape.rb +2 -11
- data/lib/rigor/type/integer_range.rb +2 -11
- data/lib/rigor/type/intersection.rb +2 -11
- data/lib/rigor/type/nominal.rb +2 -11
- data/lib/rigor/type/plain_lattice.rb +37 -0
- data/lib/rigor/type/refined.rb +72 -13
- data/lib/rigor/type/singleton.rb +2 -11
- data/lib/rigor/type/struct_class.rb +75 -0
- data/lib/rigor/type/struct_instance.rb +93 -0
- data/lib/rigor/type/tuple.rb +5 -15
- data/lib/rigor/type.rb +2 -0
- data/lib/rigor/version.rb +1 -1
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_discoverer.rb +1 -1
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable/channel_index.rb +3 -3
- data/plugins/rigor-actioncable/lib/rigor/plugin/actioncable.rb +3 -3
- data/plugins/rigor-actionmailer/lib/rigor/plugin/actionmailer/mailer_discoverer.rb +5 -13
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack/analyzer.rb +11 -17
- data/plugins/rigor-actionpack/lib/rigor/plugin/actionpack.rb +7 -10
- data/plugins/rigor-activejob/lib/rigor/plugin/activejob/job_index.rb +3 -2
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord/model_discoverer.rb +4 -4
- data/plugins/rigor-activerecord/lib/rigor/plugin/activerecord.rb +6 -8
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage/analyzer.rb +5 -7
- data/plugins/rigor-activestorage/lib/rigor/plugin/activestorage.rb +1 -2
- data/plugins/rigor-devise/lib/rigor/plugin/devise.rb +9 -11
- data/plugins/rigor-dry-struct/lib/rigor/plugin/dry_struct.rb +8 -9
- data/plugins/rigor-dry-types/lib/rigor/plugin/dry_types.rb +13 -12
- data/plugins/rigor-dry-validation/lib/rigor/plugin/dry_validation.rb +3 -4
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/analyzer.rb +8 -8
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_discoverer.rb +9 -11
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot/factory_index.rb +7 -8
- data/plugins/rigor-factorybot/lib/rigor/plugin/factorybot.rb +7 -9
- data/plugins/rigor-graphql/lib/rigor/plugin/graphql/type_scanner.rb +12 -13
- data/plugins/rigor-graphql/lib/rigor/plugin/graphql.rb +15 -23
- data/plugins/rigor-mangrove/lib/rigor/plugin/mangrove.rb +3 -3
- data/plugins/rigor-minitest/lib/rigor/plugin/minitest.rb +3 -3
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/analyzer.rb +2 -4
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n/locale_loader.rb +27 -11
- data/plugins/rigor-rails-i18n/lib/rigor/plugin/rails_i18n.rb +1 -1
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/devise_routes.rb +4 -6
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes/routes_parser.rb +12 -18
- data/plugins/rigor-rails-routes/lib/rigor/plugin/rails_routes.rb +5 -5
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_scope_index.rb +3 -4
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/let_type_resolver.rb +1 -1
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec/matcher_analyzer.rb +1 -1
- data/plugins/rigor-rspec/lib/rigor/plugin/rspec.rb +19 -14
- data/plugins/rigor-shoulda-matchers/lib/rigor/plugin/shoulda_matchers/analyzer.rb +0 -1
- data/plugins/rigor-sidekiq/lib/rigor/plugin/sidekiq/worker_index.rb +5 -4
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/assertion_recognizer.rb +2 -3
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/method_signature.rb +7 -11
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sig_parser.rb +4 -5
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/sigil_detector.rb +6 -9
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet/type_translator.rb +5 -15
- data/plugins/rigor-sorbet/lib/rigor/plugin/sorbet.rb +28 -41
- data/sig/rigor/scope.rbs +9 -1
- data/sig/rigor/type.rbs +36 -1
- metadata +49 -1
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
class Redis
|
|
2
|
+
type arg = String | Symbol | Integer | Float
|
|
3
|
+
type time = Integer | Float
|
|
4
|
+
|
|
5
|
+
type sentinel = { host: String, port: Integer?, password: String? }
|
|
6
|
+
|
|
7
|
+
type node = String
|
|
8
|
+
| { host: String?, port: Integer?, db: Integer?, password: String?, path: String?, url: String? }
|
|
9
|
+
|
|
10
|
+
# Create a new client instance
|
|
11
|
+
#
|
|
12
|
+
# @param [Hash] options
|
|
13
|
+
# @option options [String] :url (value of the environment variable REDIS_URL) a Redis URL, for a TCP connection:
|
|
14
|
+
# `redis://:[password]@[hostname]:[port]/[db]` (password, port and database are optional), for a unix socket
|
|
15
|
+
# connection: `unix://[path to Redis socket]`. This overrides all other options.
|
|
16
|
+
# @option options [String] :host ("127.0.0.1") server hostname
|
|
17
|
+
# @option options [Integer] :port (6379) server port
|
|
18
|
+
# @option options [String] :path path to server socket (overrides host and port)
|
|
19
|
+
# @option options [Float] :timeout (5.0) timeout in seconds
|
|
20
|
+
# @option options [Float] :connect_timeout (same as timeout) timeout for initial connect in seconds
|
|
21
|
+
# @option options [String] :password Password to authenticate against server
|
|
22
|
+
# @option options [Integer] :db (0) Database to select after initial connect
|
|
23
|
+
# @option options [Symbol] :driver Driver to use, currently supported: `:ruby`, `:hiredis`, `:synchrony`
|
|
24
|
+
# @option options [String] :id ID for the client connection, assigns name to current connection by sending
|
|
25
|
+
# `CLIENT SETNAME`
|
|
26
|
+
# @option options [Hash, Integer] :tcp_keepalive Keepalive values, if Integer `intvl` and `probe` are calculated
|
|
27
|
+
# based on the value, if Hash `time`, `intvl` and `probes` can be specified as a Integer
|
|
28
|
+
# @option options [Integer] :reconnect_attempts Number of attempts trying to connect
|
|
29
|
+
# @option options [Boolean] :inherit_socket (false) Whether to use socket in forked process or not
|
|
30
|
+
# @option options [Array] :sentinels List of sentinels to contact
|
|
31
|
+
# @option options [Symbol] :role (:master) Role to fetch via Sentinel, either `:master` or `:slave`
|
|
32
|
+
# @option options [Array<String, Hash{Symbol => String, Integer}>] :cluster List of cluster nodes to contact
|
|
33
|
+
# @option options [Boolean] :replica Whether to use readonly replica nodes in Redis Cluster or not
|
|
34
|
+
# @option options [Class] :connector Class of custom connector
|
|
35
|
+
#
|
|
36
|
+
# @return [Redis] a new client instance
|
|
37
|
+
def initialize: (?url: String,
|
|
38
|
+
?scheme: String,
|
|
39
|
+
?host: String,
|
|
40
|
+
?port: Integer,
|
|
41
|
+
?db: Integer,
|
|
42
|
+
?path: String,
|
|
43
|
+
?sentinels: Array[sentinel],
|
|
44
|
+
?role: :master | :slave,
|
|
45
|
+
?cluster: Array[node],
|
|
46
|
+
?repliace: boolish,
|
|
47
|
+
?timeout: time,
|
|
48
|
+
?connect_timeout: time,
|
|
49
|
+
?read_timeout: time,
|
|
50
|
+
?write_timeout: time,
|
|
51
|
+
?reconnect_attempts: Integer,
|
|
52
|
+
?reconnect_delay: Float,
|
|
53
|
+
?reconnect_delay_max: Float,
|
|
54
|
+
?password: String,
|
|
55
|
+
?driver: Symbol,
|
|
56
|
+
?inherit_socket: boolish,
|
|
57
|
+
?ssl_params: Hash[Symbol, untyped]) -> void
|
|
58
|
+
|
|
59
|
+
# Set the string value of a key.
|
|
60
|
+
#
|
|
61
|
+
# @param [String] key
|
|
62
|
+
# @param [String] value
|
|
63
|
+
# @param [Hash] options
|
|
64
|
+
# - `:ex => Integer`: Set the specified expire time, in seconds.
|
|
65
|
+
# - `:px => Integer`: Set the specified expire time, in milliseconds.
|
|
66
|
+
# - `:nx => true`: Only set the key if it does not already exist.
|
|
67
|
+
# - `:xx => true`: Only set the key if it already exist.
|
|
68
|
+
# - `:keepttl => true`: Retain the time to live associated with the key.
|
|
69
|
+
# @return [String, Boolean] `"OK"` or true, false if `:nx => true` or `:xx => true`
|
|
70
|
+
def set: ((String | Symbol) key, top value, ?ex: Integer?, ?px: Integer?, ?nx: boolish, ?xx: boolish, ?keepttl: boolish) -> (String | bool)
|
|
71
|
+
|
|
72
|
+
# Set the time to live in seconds of a key.
|
|
73
|
+
#
|
|
74
|
+
# @param [String] key
|
|
75
|
+
# @param [Integer] ttl
|
|
76
|
+
# @param [String] value
|
|
77
|
+
# @return [String] `"OK"`
|
|
78
|
+
def setex: (String key, Integer ttl, String value) -> String
|
|
79
|
+
|
|
80
|
+
# Get the value of a key.
|
|
81
|
+
#
|
|
82
|
+
# @param [String] key
|
|
83
|
+
# @return [String]
|
|
84
|
+
def get: ((String | Symbol) key) -> String?
|
|
85
|
+
|
|
86
|
+
# Delete one or more keys.
|
|
87
|
+
#
|
|
88
|
+
# @param [String, Array<String>] keys
|
|
89
|
+
# @return [Integer] number of keys that were deleted
|
|
90
|
+
def del: (*(String | Array[String]) keys) -> Integer
|
|
91
|
+
|
|
92
|
+
# Set one or more values.
|
|
93
|
+
#
|
|
94
|
+
# @example
|
|
95
|
+
# redis.mset("key1", "v1", "key2", "v2")
|
|
96
|
+
# # => "OK"
|
|
97
|
+
#
|
|
98
|
+
# @param [Array<String>] args array of keys and values
|
|
99
|
+
# @return [String] `"OK"`
|
|
100
|
+
#
|
|
101
|
+
# @see #mapped_mset
|
|
102
|
+
def mset: (*String args) -> String
|
|
103
|
+
|
|
104
|
+
# Get the values of all the given keys.
|
|
105
|
+
#
|
|
106
|
+
# @example
|
|
107
|
+
# redis.mget("key1", "key2")
|
|
108
|
+
# # => ["v1", "v2"]
|
|
109
|
+
#
|
|
110
|
+
# @param [Array<String>] keys
|
|
111
|
+
# @return [Array<String>] an array of values for the specified keys
|
|
112
|
+
#
|
|
113
|
+
# @see #mapped_mget
|
|
114
|
+
def mget: (*String keys) -> Array[String?]
|
|
115
|
+
| [T] (*String keys) { (Array[String?]) -> T } -> T
|
|
116
|
+
|
|
117
|
+
# Decrement the integer value of a key by one.
|
|
118
|
+
#
|
|
119
|
+
# @example
|
|
120
|
+
# redis.decr("value")
|
|
121
|
+
# # => 4
|
|
122
|
+
#
|
|
123
|
+
# @param [String] key
|
|
124
|
+
# @return [Integer] value after decrementing it
|
|
125
|
+
def decr: (String key) -> Integer
|
|
126
|
+
|
|
127
|
+
# Decrement the integer value of a key by the given number.
|
|
128
|
+
#
|
|
129
|
+
# @example
|
|
130
|
+
# redis.decrby("value", 5)
|
|
131
|
+
# # => 0
|
|
132
|
+
#
|
|
133
|
+
# @param [String] key
|
|
134
|
+
# @param [Integer] decrement
|
|
135
|
+
# @return [Integer] value after decrementing it
|
|
136
|
+
def decrby: (String key, Integer decrement) -> Integer
|
|
137
|
+
|
|
138
|
+
# Increment the integer value of a key by one.
|
|
139
|
+
#
|
|
140
|
+
# @example
|
|
141
|
+
# redis.incr("value")
|
|
142
|
+
# # => 6
|
|
143
|
+
#
|
|
144
|
+
# @param [String] key
|
|
145
|
+
# @return [Integer] value after incrementing it
|
|
146
|
+
def incr: (String key) -> Integer
|
|
147
|
+
|
|
148
|
+
# Increment the integer value of a key by the given integer number.
|
|
149
|
+
#
|
|
150
|
+
# @example
|
|
151
|
+
# redis.incrby("value", 5)
|
|
152
|
+
# # => 10
|
|
153
|
+
#
|
|
154
|
+
# @param [String] key
|
|
155
|
+
# @param [Integer] increment
|
|
156
|
+
# @return [Integer] value after incrementing it
|
|
157
|
+
def incrby: (String key, Integer increment) -> Integer
|
|
158
|
+
|
|
159
|
+
interface _Pipelined
|
|
160
|
+
def get: (String key) -> Future[String?]
|
|
161
|
+
|
|
162
|
+
def set: (String key, top value, ?ex: Integer?, ?px: Integer?, ?nx: boolish, ?xx: boolish, ?keepttl: boolish) -> Future[String]
|
|
163
|
+
|
|
164
|
+
def decr: (String key) -> Future[Integer]
|
|
165
|
+
|
|
166
|
+
def decrby: (String key, Integer decrement) -> Future[Integer]
|
|
167
|
+
|
|
168
|
+
def incr: (String key) -> Future[Integer]
|
|
169
|
+
|
|
170
|
+
def incrby: (String key, Integer increment) -> Future[Integer]
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def pipelined: () { (self & _Pipelined) -> void } -> Array[String | Integer]
|
|
174
|
+
|
|
175
|
+
# Mark the start of a transaction block.
|
|
176
|
+
#
|
|
177
|
+
# Passing a block is optional.
|
|
178
|
+
#
|
|
179
|
+
# @example With a block
|
|
180
|
+
# redis.multi do |multi|
|
|
181
|
+
# multi.set("key", "value")
|
|
182
|
+
# multi.incr("counter")
|
|
183
|
+
# end # => ["OK", 6]
|
|
184
|
+
#
|
|
185
|
+
# @example Without a block
|
|
186
|
+
# redis.multi
|
|
187
|
+
# # => "OK"
|
|
188
|
+
# redis.set("key", "value")
|
|
189
|
+
# # => "QUEUED"
|
|
190
|
+
# redis.incr("counter")
|
|
191
|
+
# # => "QUEUED"
|
|
192
|
+
# redis.exec
|
|
193
|
+
# # => ["OK", 6]
|
|
194
|
+
#
|
|
195
|
+
# @yield [multi] the commands that are called inside this block are cached
|
|
196
|
+
# and written to the server upon returning from it
|
|
197
|
+
# @yieldparam [Redis] multi `self`
|
|
198
|
+
#
|
|
199
|
+
# @return [String, Array<...>]
|
|
200
|
+
# - when a block is not given, `OK`
|
|
201
|
+
# - when a block is given, an array with replies
|
|
202
|
+
#
|
|
203
|
+
# @see #watch
|
|
204
|
+
# @see #unwatch
|
|
205
|
+
def multi: () -> String
|
|
206
|
+
| () { (self) -> void } -> Array[String | Integer]
|
|
207
|
+
|
|
208
|
+
# Ping the server.
|
|
209
|
+
#
|
|
210
|
+
# @param [optional, String] message
|
|
211
|
+
# @return [String] `PONG`
|
|
212
|
+
def ping: (?String? message) -> String
|
|
213
|
+
|
|
214
|
+
def zcard: (_ToS key) -> Integer
|
|
215
|
+
def zadd: (_ToS key, *untyped args, ?nx: bool, ?ch: bool, ?incr: bool) -> (bool | Integer | Float)
|
|
216
|
+
| (_ToS key, *untyped args, ?xx: bool, ?ch: bool, ?incr: bool) -> (bool | Integer | Float)
|
|
217
|
+
def zincrby: (_ToS key, Integer | Float | "-inf" | "+inf" increment, String member) -> Float
|
|
218
|
+
def zrem: (_ToS key, String | Array[String] member) -> (bool | Integer)
|
|
219
|
+
|
|
220
|
+
# Disconnect the client as quickly and silently as possible.
|
|
221
|
+
def close: () -> void
|
|
222
|
+
|
|
223
|
+
alias disconnect! close
|
|
224
|
+
|
|
225
|
+
# Set a key's time to live in seconds.
|
|
226
|
+
#
|
|
227
|
+
# @param [String] key
|
|
228
|
+
# @param [Integer] seconds time to live
|
|
229
|
+
# @return [Boolean] whether the timeout was set or not
|
|
230
|
+
def expire: (String key, Integer seconds) -> bool
|
|
231
|
+
|
|
232
|
+
# Evaluate Lua script by its SHA.
|
|
233
|
+
#
|
|
234
|
+
# @example EVALSHA without KEYS nor ARGV
|
|
235
|
+
# redis.evalsha(sha)
|
|
236
|
+
# # => <depends on script>
|
|
237
|
+
# @example EVALSHA with KEYS and ARGV as array arguments
|
|
238
|
+
# redis.evalsha(sha, ["k1", "k2"], ["a1", "a2"])
|
|
239
|
+
# # => <depends on script>
|
|
240
|
+
# @example EVALSHA with KEYS and ARGV in a hash argument
|
|
241
|
+
# redis.evalsha(sha, :keys => ["k1", "k2"], :argv => ["a1", "a2"])
|
|
242
|
+
# # => <depends on script>
|
|
243
|
+
#
|
|
244
|
+
# @param [Array<String>] keys optional array with keys to pass to the script
|
|
245
|
+
# @param [Array<String>] argv optional array with arguments to pass to the script
|
|
246
|
+
# @param [Hash] options
|
|
247
|
+
# - `:keys => Array<String>`: optional array with keys to pass to the script
|
|
248
|
+
# - `:argv => Array<String>`: optional array with arguments to pass to the script
|
|
249
|
+
# @return depends on the script
|
|
250
|
+
#
|
|
251
|
+
# @see #script
|
|
252
|
+
# @see #eval
|
|
253
|
+
def evalsha: (String, ?Array[String], ?Array[String], ?keys: Array[String], ?argv: Array[String]) -> untyped
|
|
254
|
+
|
|
255
|
+
# Control remote script registry.
|
|
256
|
+
#
|
|
257
|
+
# @example Load a script
|
|
258
|
+
# sha = redis.script(:load, "return 1")
|
|
259
|
+
# # => <sha of this script>
|
|
260
|
+
# @example Check if a script exists
|
|
261
|
+
# redis.script(:exists, sha)
|
|
262
|
+
# # => true
|
|
263
|
+
# @example Check if multiple scripts exist
|
|
264
|
+
# redis.script(:exists, [sha, other_sha])
|
|
265
|
+
# # => [true, false]
|
|
266
|
+
# @example Flush the script registry
|
|
267
|
+
# redis.script(:flush)
|
|
268
|
+
# # => "OK"
|
|
269
|
+
# @example Kill a running script
|
|
270
|
+
# redis.script(:kill)
|
|
271
|
+
# # => "OK"
|
|
272
|
+
#
|
|
273
|
+
# @param [String] subcommand e.g. `exists`, `flush`, `load`, `kill`
|
|
274
|
+
# @param [Array<String>] args depends on subcommand
|
|
275
|
+
# @return [String, Boolean, Array<Boolean>, ...] depends on subcommand
|
|
276
|
+
#
|
|
277
|
+
# @see #eval
|
|
278
|
+
# @see #evalsha
|
|
279
|
+
def script: (Symbol, *untyped) -> untyped
|
|
280
|
+
|
|
281
|
+
def with: [T] () { (self) -> T } -> T
|
|
282
|
+
|
|
283
|
+
def hdel: (arg key, *arg fields) -> Integer
|
|
284
|
+
| (arg key, Array[arg]) -> Integer
|
|
285
|
+
def hexists: (arg key, arg field) -> bool
|
|
286
|
+
def hget: (arg key, arg field) -> String?
|
|
287
|
+
def hgetall: (arg key) -> Hash[String, String?]
|
|
288
|
+
def hincrby: (arg key, arg field, _ToI | _ToInt increment) -> Integer
|
|
289
|
+
def hincrbyfloat: (arg key, arg field, _ToF increment) -> Float
|
|
290
|
+
def hkeys: (arg key) -> Array[String]
|
|
291
|
+
def hlen: (arg key) -> Integer
|
|
292
|
+
|
|
293
|
+
def hmget: (arg key, arg field1) -> [String?]
|
|
294
|
+
| (arg key, [arg]) -> [String?]
|
|
295
|
+
| (arg key, arg field1, arg field2) -> [String?, String?]
|
|
296
|
+
| (arg key, [arg, arg]) -> [String?, String?]
|
|
297
|
+
| (arg key, arg field1, arg field2, arg field3) -> [String?, String?, String?]
|
|
298
|
+
| (arg key, [arg, arg, arg]) -> [String?, String?, String?]
|
|
299
|
+
| (arg key, arg field1, arg field2, arg field3, arg field4) -> [String?, String?, String?, String?]
|
|
300
|
+
| (arg key, [arg, arg, arg, arg]) -> [String?, String?, String?, String?]
|
|
301
|
+
| (arg key, arg field1, arg field2, arg field3, arg field4, arg field5) -> [String?, String?, String?, String?, String?]
|
|
302
|
+
| (arg key, [arg, arg, arg, arg, arg]) -> [String?, String?, String?, String?, String?]
|
|
303
|
+
| (arg key, arg field1, arg field2, arg field3, arg field4, arg field5, arg field6) -> [String?, String?, String?, String?, String?, String?]
|
|
304
|
+
| (arg key, [arg, arg, arg, arg, arg, arg]) -> [String?, String?, String?, String?, String?, String?]
|
|
305
|
+
| (arg key, arg field1, arg field2, arg field3, arg field4, arg field5, arg field6, arg field7) -> [String?, String?, String?, String?, String?, String?, String?]
|
|
306
|
+
| (arg key, [arg, arg, arg, arg, arg, arg, arg]) -> [String?, String?, String?, String?, String?, String?, String?]
|
|
307
|
+
| (arg key, *arg) -> Array[String?]
|
|
308
|
+
| (arg key, Array[arg]) -> Array[String?]
|
|
309
|
+
|
|
310
|
+
def hmset: (arg key, arg field1, arg value1) -> "OK"
|
|
311
|
+
| (arg key, [arg, arg]) -> "OK"
|
|
312
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2) -> "OK"
|
|
313
|
+
| (arg key, [arg, arg, arg, arg]) -> "OK"
|
|
314
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3) -> "OK"
|
|
315
|
+
| (arg key, [arg, arg, arg, arg, arg, arg]) -> "OK"
|
|
316
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4) -> "OK"
|
|
317
|
+
| (arg key, [arg, arg, arg, arg, arg, arg, arg, arg]) -> "OK"
|
|
318
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5) -> "OK"
|
|
319
|
+
| (arg key, [arg, arg, arg, arg, arg, arg, arg, arg, arg, arg]) -> "OK"
|
|
320
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5, arg field6, arg value6) -> "OK"
|
|
321
|
+
| (arg key, [arg, arg, arg, arg, arg, arg, arg, arg, arg, arg, arg, arg]) -> "OK"
|
|
322
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5, arg field6, arg value6, *arg) -> "OK"
|
|
323
|
+
| (arg key, Array[arg]) -> "OK"
|
|
324
|
+
| (arg key, Hash[arg, arg]) -> "OK"
|
|
325
|
+
|
|
326
|
+
def hrandfield: (arg key) -> String?
|
|
327
|
+
| (arg key, Integer count) -> Array[String]
|
|
328
|
+
| (arg key, Integer count, with_values: false) -> Array[String]
|
|
329
|
+
| (arg key, Integer count, with_values: true) -> Array[[String, String]]
|
|
330
|
+
|
|
331
|
+
def hset: (arg key, arg field1, arg value1) -> Integer
|
|
332
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2) -> Integer
|
|
333
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3) -> Integer
|
|
334
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4) -> Integer
|
|
335
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5) -> Integer
|
|
336
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5, arg field6, arg value6) -> Integer
|
|
337
|
+
| (arg key, arg field1, arg value1, arg field2, arg value2, arg field3, arg value3, arg field4, arg value4, arg field5, arg value5, arg field6, arg value6, *arg) -> Integer
|
|
338
|
+
| (arg key, Hash[arg, arg]) -> Integer
|
|
339
|
+
|
|
340
|
+
def hsetnx: (arg key, arg field, arg value) -> bool
|
|
341
|
+
|
|
342
|
+
def hvals: (arg key) -> Array[String]
|
|
343
|
+
|
|
344
|
+
def mapped_hmget: (arg key, *arg keys) -> Hash[String, String?]
|
|
345
|
+
| (arg key, Array[arg] keys) -> Hash[String, String?]
|
|
346
|
+
|
|
347
|
+
def mapped_hmset: (arg key, Hash[arg, arg]) -> "OK"
|
|
348
|
+
end
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Rigor-side patches on top of the gem_rbs_collection's
|
|
2
|
+
# redis/4.2/ surface to cover common methods the vendored 4.2
|
|
3
|
+
# snapshot lacks. Real-world Rails projects (Discourse / Forem /
|
|
4
|
+
# Canvas) call these from cache layers and Sidekiq integration.
|
|
5
|
+
#
|
|
6
|
+
# Source: hand-written by Rigor maintainers.
|
|
7
|
+
# License: MPL-2.0 (matches the rest of Rigor).
|
|
8
|
+
#
|
|
9
|
+
# Add new entries when a project flags `call.undefined-method`
|
|
10
|
+
# for a Redis instance method that should exist.
|
|
11
|
+
|
|
12
|
+
class Redis
|
|
13
|
+
# Generic key operations.
|
|
14
|
+
def exists: (*arg keys) -> Integer
|
|
15
|
+
def exists?: (*arg keys) -> bool
|
|
16
|
+
def keys: (?String pattern) -> Array[String]
|
|
17
|
+
def type: (arg key) -> String
|
|
18
|
+
def ttl: (arg key) -> Integer
|
|
19
|
+
def pttl: (arg key) -> Integer
|
|
20
|
+
def expireat: (arg key, Integer unix_time) -> bool
|
|
21
|
+
def pexpire: (arg key, Integer milliseconds) -> bool
|
|
22
|
+
def pexpireat: (arg key, Integer unix_time_ms) -> bool
|
|
23
|
+
def persist: (arg key) -> bool
|
|
24
|
+
def rename: (arg from, arg to) -> String
|
|
25
|
+
def renamex: (arg from, arg to) -> bool
|
|
26
|
+
def renamenx: (arg from, arg to) -> bool
|
|
27
|
+
def randomkey: () -> String?
|
|
28
|
+
def touch: (*arg keys) -> Integer
|
|
29
|
+
def unlink: (*arg keys) -> Integer
|
|
30
|
+
def dump: (arg key) -> String?
|
|
31
|
+
def restore: (arg key, Integer ttl, String serialized, **untyped) -> String
|
|
32
|
+
|
|
33
|
+
# Cursor scans.
|
|
34
|
+
def scan: (?Integer cursor, ?match: String, ?count: Integer, ?type: String) -> [String, Array[String]]
|
|
35
|
+
def scan_each: (?match: String, ?count: Integer, ?type: String) { (String) -> void } -> self
|
|
36
|
+
| (?match: String, ?count: Integer, ?type: String) -> Enumerator[String, self]
|
|
37
|
+
def sscan: (arg key, ?Integer cursor, ?match: String, ?count: Integer) -> [String, Array[String]]
|
|
38
|
+
def sscan_each: (arg key, ?match: String, ?count: Integer) { (String) -> void } -> self
|
|
39
|
+
| (arg key, ?match: String, ?count: Integer) -> Enumerator[String, self]
|
|
40
|
+
def hscan: (arg key, ?Integer cursor, ?match: String, ?count: Integer) -> [String, Array[[String, String]]]
|
|
41
|
+
def hscan_each: (arg key, ?match: String, ?count: Integer) { ([String, String]) -> void } -> self
|
|
42
|
+
| (arg key, ?match: String, ?count: Integer) -> Enumerator[[String, String], self]
|
|
43
|
+
def zscan: (arg key, ?Integer cursor, ?match: String, ?count: Integer) -> [String, Array[[String, Float]]]
|
|
44
|
+
|
|
45
|
+
# String / counter / set operations the curated 4.2 snapshot
|
|
46
|
+
# didn't cover (real-world projects call them).
|
|
47
|
+
def append: (arg key, String value) -> Integer
|
|
48
|
+
def getset: (arg key, String value) -> String?
|
|
49
|
+
def strlen: (arg key) -> Integer
|
|
50
|
+
def getrange: (arg key, Integer start, Integer stop) -> String
|
|
51
|
+
def setrange: (arg key, Integer offset, String value) -> Integer
|
|
52
|
+
def bitcount: (arg key, ?Integer start, ?Integer stop) -> Integer
|
|
53
|
+
def bitop: (String operation, arg destkey, *arg keys) -> Integer
|
|
54
|
+
|
|
55
|
+
# Lists.
|
|
56
|
+
def lpush: (arg key, *untyped values) -> Integer
|
|
57
|
+
def rpush: (arg key, *untyped values) -> Integer
|
|
58
|
+
def lpop: (arg key, ?Integer count) -> (String | Array[String] | nil)
|
|
59
|
+
def rpop: (arg key, ?Integer count) -> (String | Array[String] | nil)
|
|
60
|
+
def lrange: (arg key, Integer start, Integer stop) -> Array[String]
|
|
61
|
+
def llen: (arg key) -> Integer
|
|
62
|
+
def lindex: (arg key, Integer index) -> String?
|
|
63
|
+
def lrem: (arg key, Integer count, untyped value) -> Integer
|
|
64
|
+
def ltrim: (arg key, Integer start, Integer stop) -> String
|
|
65
|
+
def lset: (arg key, Integer index, untyped value) -> String
|
|
66
|
+
def blpop: (*untyped, ?timeout: Numeric) -> [String, String]?
|
|
67
|
+
def brpop: (*untyped, ?timeout: Numeric) -> [String, String]?
|
|
68
|
+
|
|
69
|
+
# Sets.
|
|
70
|
+
def sadd: (arg key, *untyped members) -> Integer
|
|
71
|
+
def srem: (arg key, *untyped members) -> Integer
|
|
72
|
+
def smembers: (arg key) -> Array[String]
|
|
73
|
+
def scard: (arg key) -> Integer
|
|
74
|
+
def sismember: (arg key, untyped member) -> bool
|
|
75
|
+
def sinter: (*arg keys) -> Array[String]
|
|
76
|
+
def sunion: (*arg keys) -> Array[String]
|
|
77
|
+
def sdiff: (*arg keys) -> Array[String]
|
|
78
|
+
def spop: (arg key, ?Integer count) -> (String | Array[String] | nil)
|
|
79
|
+
def srandmember: (arg key, ?Integer count) -> (String | Array[String] | nil)
|
|
80
|
+
|
|
81
|
+
# Sorted sets the curated snapshot only partially covered.
|
|
82
|
+
def zrange: (arg key, Integer start, Integer stop, ?withscores: bool, ?rev: bool, ?limit: Array[Integer]) -> (Array[String] | Array[[String, Float]])
|
|
83
|
+
def zrangebyscore: (arg key, untyped min, untyped max, ?withscores: bool, ?limit: Array[Integer]) -> (Array[String] | Array[[String, Float]])
|
|
84
|
+
def zrevrange: (arg key, Integer start, Integer stop, ?withscores: bool) -> (Array[String] | Array[[String, Float]])
|
|
85
|
+
def zrevrangebyscore: (arg key, untyped max, untyped min, ?withscores: bool, ?limit: Array[Integer]) -> (Array[String] | Array[[String, Float]])
|
|
86
|
+
def zscore: (arg key, String member) -> Float?
|
|
87
|
+
def zrank: (arg key, String member) -> Integer?
|
|
88
|
+
def zrevrank: (arg key, String member) -> Integer?
|
|
89
|
+
def zcount: (arg key, untyped min, untyped max) -> Integer
|
|
90
|
+
def zpopmin: (arg key, ?Integer count) -> (Array[[String, Float]] | [String, Float] | nil)
|
|
91
|
+
def zpopmax: (arg key, ?Integer count) -> (Array[[String, Float]] | [String, Float] | nil)
|
|
92
|
+
|
|
93
|
+
# Pub/Sub.
|
|
94
|
+
def publish: (String channel, String message) -> Integer
|
|
95
|
+
def subscribe: (*String channels) { (untyped) -> void } -> void
|
|
96
|
+
def unsubscribe: (*String channels) -> void
|
|
97
|
+
def psubscribe: (*String patterns) { (untyped) -> void } -> void
|
|
98
|
+
def punsubscribe: (*String patterns) -> void
|
|
99
|
+
|
|
100
|
+
# Server / connection.
|
|
101
|
+
def info: (?String section) -> Hash[String, String]
|
|
102
|
+
def dbsize: () -> Integer
|
|
103
|
+
def flushdb: () -> String
|
|
104
|
+
def flushall: () -> String
|
|
105
|
+
def select: (Integer db) -> String
|
|
106
|
+
def auth: (String password) -> String
|
|
107
|
+
def wait: (Integer numreplicas, Integer timeout) -> Integer
|
|
108
|
+
def time: () -> [String, String]
|
|
109
|
+
def lastsave: () -> Integer
|
|
110
|
+
def echo: (String value) -> String
|
|
111
|
+
def shutdown: (?String save_mode) -> nil
|
|
112
|
+
def client: (String command, *untyped) -> untyped
|
|
113
|
+
|
|
114
|
+
# Scripting.
|
|
115
|
+
def eval: (String script, ?Array[String] keys, ?Array[String] argv, ?keys: Array[String], ?argv: Array[String]) -> untyped
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Redis::Cluster - used by gitlab / canvas.
|
|
119
|
+
class Redis::Cluster
|
|
120
|
+
def _client: () -> untyped
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Redis singleton class methods.
|
|
124
|
+
class Redis
|
|
125
|
+
def self.patch: (*untyped) -> untyped
|
|
126
|
+
def self.exists_returns_integer: () -> bool
|
|
127
|
+
def self.exists_returns_integer=: (bool) -> bool
|
|
128
|
+
def self.current: () -> Redis
|
|
129
|
+
def self.current=: (Redis) -> Redis
|
|
130
|
+
end
|