Class: SlateDb::WriteBatch

Inherits:
Object
  • Object
show all
Defined in:
lib/slatedb/write_batch.rb

Instance Method Summary collapse

Instance Method Details

#delete(key) ⇒ self

Add a delete operation to the batch.

Examples:

batch.delete("key")

Parameters:

  • key (String)

    The key to delete

Returns:

  • (self)

    Returns self for method chaining



33
34
35
36
# File 'lib/slatedb/write_batch.rb', line 33

def delete(key)
  _delete(key)
  self
end

#put(key, value, ttl: nil) ⇒ self

Add a put operation to the batch.

Examples:

batch.put("key", "value")
batch.put("key2", "value2", ttl: 60_000)

Parameters:

  • key (String)

    The key to store

  • value (String)

    The value to store

  • ttl (Integer, nil) (defaults to: nil)

    Time-to-live in milliseconds

Returns:

  • (self)

    Returns self for method chaining



16
17
18
19
20
21
22
23
# File 'lib/slatedb/write_batch.rb', line 16

def put(key, value, ttl: nil)
  if ttl
    _put_with_options(key, value, { ttl: ttl })
  else
    _put(key, value)
  end
  self
end