Module: Redis::Commands::Bless
| Relationships & Source Files | |
| Extension / Inclusion / Inheritance Descendants | |
|
Included In:
| |
| Defined in: | lib/redis/commands/bless.rb |
Overview
The BLESS command family (Redis 8.12): per-key protection flags that
shield a key from memory-pressure actions. The only flag so far is
NO-EVICT, which excludes the key from the eviction policy.
Flags are passed to the server verbatim: no client-side validation or
normalization is done, so spell them the way the server does
("NO-EVICT"). An unknown flag is rejected by the server with a
::Redis::CommandError.
Instance Method Summary
-
#bless_clear(key, flag) ⇒ Boolean
Remove a protection flag from a key.
-
#bless_get(key) ⇒ Array<String>
Return the active protection flags of a key.
-
#bless_scan(cursor, flag, count: nil) ⇒ Array(String, Array<String>)
Incrementally iterate the keys of the current database that carry the given protection flag.
-
#bless_scan_each(flag, **options, &block) ⇒ Enumerator
Iterate every key of the current database that carries the given protection flag, driving #bless_scan until the cursor wraps around.
-
#bless_set(key, flag) ⇒ Boolean
Add a protection flag to a key.
Instance Method Details
#bless_clear(key, flag) ⇒ Boolean
Remove a protection flag from a key.
# File 'lib/redis/commands/bless.rb', line 57
def bless_clear(key, flag) send_command([:bless, "CLEAR", key, flag], &Boolify) end
#bless_get(key) ⇒ Array<String>
Return the active protection flags of a key.
# File 'lib/redis/commands/bless.rb', line 25
def bless_get(key) send_command([:bless, "GET", key]) end
#bless_scan(cursor, flag, count: nil) ⇒ Array(String, Array<String>)
On Redis::Cluster the driver walks the nodes one by one, as it
does for SCAN, encoding the node index into the returned cursor, so
a full iteration covers every shard. Inside pipelined/multi the
command is sent to a single node instead and only that node's keys
are returned.
Incrementally iterate the keys of the current database that carry the
given protection flag. Like SCAN, a full iteration is complete when
the returned cursor is "0".
# File 'lib/redis/commands/bless.rb', line 83
def bless_scan(cursor, flag, count: nil) args = [:bless, "SCAN", cursor, flag] args << "COUNT" << Integer(count) if count send_command(args) end
#bless_scan_each(flag, **options, &block) ⇒ Enumerator
Iterate every key of the current database that carries the given protection flag, driving #bless_scan until the cursor wraps around.
# File 'lib/redis/commands/bless.rb', line 103
def bless_scan_each(flag, **, &block) return to_enum(:bless_scan_each, flag, **) unless block_given? cursor = 0 loop do cursor, keys = bless_scan(cursor, flag, **) keys.each(&block) break if cursor == "0" end end
#bless_set(key, flag) ⇒ Boolean
Add a protection flag to a key.
# File 'lib/redis/commands/bless.rb', line 41
def bless_set(key, flag) send_command([:bless, "SET", key, flag], &Boolify) end