github.com/scottcagno/storage@v1.8.0/storage.go (about)

     1  package storage
     2  
     3  import (
     4  	"github.com/scottcagno/storage/pkg/lsmt/binary"
     5  )
     6  
     7  // Config is an interface for this package
     8  type Config interface {
     9  	CheckConfig() Config
    10  }
    11  
    12  // Storage is an interface for this package
    13  type Storage interface {
    14  
    15  	// basic operations
    16  	Has(key string) bool
    17  	Put(key string, value []byte) error
    18  	Get(key string) ([]byte, error)
    19  	Del(key string) error
    20  	Sync() error
    21  	Close() error
    22  
    23  	// batch operations
    24  	PutBatch(batch *binary.Batch) error
    25  	GetBatch(keys ...string) (*binary.Batch, error)
    26  
    27  	//Backup(w io.Writer, it Iterator) error
    28  	//Drop(re *regexp.Regexp) error
    29  
    30  	// stats
    31  	Stats() (StorageStats, error)
    32  }
    33  
    34  // StorageStats is an interface for this package
    35  type StorageStats interface {
    36  	String() string
    37  	JSON() (string, error)
    38  }
    39  
    40  // Examples of struct field tags and their meanings:
    41  //
    42  //   // Field appears in JSON as key "myName".
    43  //   Field int `json:"myName"`
    44  //
    45  //   // Field appears in JSON as key "myName" and
    46  //   // the field is omitted from the object if its value is empty,
    47  //   // as defined above.
    48  //   Field int `json:"myName,omitempty"`
    49  //
    50  //   // Field appears in JSON as key "Field" (the default), but
    51  //   // the field is skipped if empty.
    52  //   // Note the leading comma.
    53  //   Field int `json:",omitempty"`
    54  //
    55  //   // Field is ignored by this package.
    56  //   Field int `json:"-"`
    57  //
    58  //   // Field appears in JSON as key "-".
    59  //   Field int `json:"-,"`
    60  //
    61  // The "string" option signals that a field is stored as JSON inside a
    62  // JSON-encoded string. It applies only to fields of string, floating point,
    63  // integer, or boolean types. This extra level of encoding is sometimes used
    64  // when communicating with JavaScript programs:
    65  //
    66  //    Int64String int64 `json:",string"`