Class Bucket

extends ServiceResourceProxy
A storage bucket is a key-value mapping that resides outside the current process and that can be persisted across application and device restarts.
Buckets are referred to via a schema and a path. The scheme indicates the volatility and storage medium of the bucket and the path allows separating buckets.

Class summary


SCHEME-FLASH -> any
SCHEME-RAM -> any
open uri/string -> Bucket
open --ram/bool path/string -> Bucket
open --flash/bool path/string -> Bucket
open --scheme/string --path/string -> Bucket
Opens a storage bucket using the given scheme and path.

Statics

Opens a storage bucket with using the schema and path parsed from the given uri.
The format of the uri is <scheme>:<path> and it is common to use qualified paths that include the domain name of the bucket owner, e.g. "flash:toitlang.org/jag".

open --ram/bool path/string -> Bucket
Opens a storage bucket using the SCHEME-RAM scheme and the given path.

open --flash/bool path/string -> Bucket
Opens a storage bucket using the SCHEME-FLASH scheme and the given path.

open --scheme/string --path/string -> Bucket
Opens a storage bucket using the given scheme and path.

SCHEME-RAM -> any

Methods

close -> none

get key/string -> any

get key/string [--if-absent] -> any

get key/string [--if-present] -> any

get key/string [--if-present] [--if-absent] -> any

get key/string [--init] -> any

operator [] key/string -> any

operator []= key/string value/any -> any

operator == other/any -> bool
Whether this object is equal to the other.
By default, identical is used for equality.
Inheritance
Classes overwrite this operator to get an equality specific to their needs. Equality operators often compare the type and field contents. For example:

class Pin:
  number/int

  constructor .number:

  operator == other:
    if other is not Pin: return false
    return number == other.number
A class doesn't have to follow the above format, but it must keep the operator in sync with any hash-code method. That is, if a class has a hash-code member, then the equality and hash-code must agree. If two instances are equal (a == b), then their hash codes must also be equal (a.hash-code == b.hash-code).

remove key/string -> none

Stringifies this object.
Inheritance
Objects that need a human-friendly string representation should overwrite this method. The default string is based on the internal class-ID.