Skip to content

Instantly share code, notes, and snippets.

@BrianHicks
Created February 2, 2014 22:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianHicks/8775570 to your computer and use it in GitHub Desktop.
Save BrianHicks/8775570 to your computer and use it in GitHub Desktop.
Data Storage and Syncing

Data Storage and Syncing with LevelDB

So here's a thought for a Go interface that would store data to memory or disk and sync it with other instances in an intermittently connected manner.

Querying

The store looks like this:

type Range struct {
  Start []byte
  End   []byte
  DB    *Store
}

// Range would implement Ranger
type Ranger interface {
  func First()      (*Record, error)
  func Last()       (*Record, error)
  func All()        (chan *Record, error)
  func AllReverse() (chan *Record, error)
}

Then you can do DB.RangeByPrefix("selected").First() and get a record.

TODO: Writing

TODO: Syncing (but use a log)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment