mysqlindexer: implement Get, Set, Delete

Change-Id: I5670bfc9ac91044be663f248c034ae20c11562bb
This commit is contained in:
Brad Fitzpatrick 2012-03-25 00:30:22 -07:00
parent cc75c449cf
commit 401f07f6cf
1 changed files with 6 additions and 3 deletions

View File

@ -47,15 +47,18 @@ func (ms *myIndexStorage) CommitBatch(b index.BatchMutation) error {
}
func (ms *myIndexStorage) Get(key string) (value string, err error) {
panic("TODO(bradfitz): implement")
err = ms.db.QueryRow("SELECT v FROM rows WHERE k=?", key).Scan(&value)
return
}
func (ms *myIndexStorage) Set(key, value string) error {
return errors.New("TODO(bradfitz): implement")
_, err := ms.db.Exec("INSERT INTO rows (k, v) VALUES (?, ?)", key, value)
return err
}
func (ms *myIndexStorage) Delete(key string) error {
return errors.New("TODO(bradfitz): implement")
_, err := ms.db.Exec("DELETE FROM rows WHERE k=?", key)
return err
}
func (ms *myIndexStorage) Find(key string) index.Iterator {