Documentation
¶
Overview ¶
Example ¶
package main import ( "fmt" "github.com/eng618/go-eng/interview/db" ) func main() { db := db.NewDatabase() t := db.Set("foo", "bar") fmt.Println("just set foo to:", db.Get("foo")) db.Set("foo", "baz") fmt.Println("the latest foo is:", db.Get("foo")) // You can use the common ok idiom to get a key with a particular time stamp. if val, ok := db.GetForTime("foo", t); ok { fmt.Println("the foo at", t, ":", val) } db.Set("age", 36) age := db.Get("age") fmt.Println("the age in database is:", age) db.Print() }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InMemDB ¶
type InMemDB struct {
// contains filtered or unexported fields
}
InMemDB is a simple in memory database.
func NewDatabase ¶
func NewDatabase() *InMemDB
NewDatabase instantiates a new instance of a database.
func (*InMemDB) GetForTime ¶
Get attempts to retrieve the supplied key from an existing database.
Click to show internal directories.
Click to hide internal directories.