Method: AsyncStorage::Allocator#get!

Defined in:
lib/async_storage/allocator.rb

#get!Object

Sync get value with a given value

Returns:

  • (Object)

    Return the result from resolver



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/async_storage/allocator.rb', line 57

def get!
  breaker.run(fallback: -> { fetch! }) do
    connection do |redis|
      raw_head = redis.get(naming.head)
      case raw_head
      when CTRL[:executed]
        read_body(redis) || begin
          update!(redis) unless redis.exists?(naming.body)
        end
      when CTRL[:missing], CTRL[:enqueued]
        update!(redis)
      else
        raise AsyncStorage::Error, format('the key %<k>s have an invalid value. Only "1" or "0" values are expected. And we got %<v>p', v: raw_head, k: naming.head)
      end
    end
  end
end