Skip to content

release sets negative slots #70

@sampatbadhe

Description

@sampatbadhe

When all slots are released, negative slots are created, allowing you to reserve slots that are more than available. Is this to be expected, or should we restrict releasing slot once all slots have been released?

3.1.0 :001 > slots = Kredis.slots "myslots", available: 3
  Kredis  (2.0ms)  Connected to shared
 =>
#<Kredis::Types::Slots:0x0000000114b5eb58
...
3.1.0 :002 > slots.get
  Kredis Proxy (1.8ms)  GET myslots
 => nil
3.1.0 :003 > slots.available
 => 3
3.1.0 :004 > slots.reserve
  Kredis Proxy (0.5ms)  INCR myslots
 => true
3.1.0 :005 > slots.get
  Kredis Proxy (0.4ms)  GET myslots
 => "1"
3.1.0 :006 > slots.available
 => 3
3.1.0 :007 > slots.release
  Kredis Proxy (0.3ms)  DECR myslots
 => 0
3.1.0 :008 > slots.get
  Kredis Proxy (0.4ms)  GET myslots
 => "0"
3.1.0 :009 > slots.release
  Kredis Proxy (0.4ms)  DECR myslots
 => -1
3.1.0 :010 > slots.get
  Kredis Proxy (0.5ms)  GET myslots
 => "-1"
3.1.0 :011 > slots.available
 => 3
3.1.0 :012 > slots.release
  Kredis Proxy (0.5ms)  DECR myslots
 => -2
3.1.0 :013 > slots.available
 => 3
3.1.0 :014 > slots.reserve
  Kredis Proxy (0.4ms)  INCR myslots
 => true
3.1.0 :015 > slots.get
  Kredis Proxy (0.3ms)  GET myslots
 => "-1"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions