Compare commits
No commits in common. "main" and "v0.0.1" have entirely different histories.
@ -148,8 +148,7 @@ func (store *Store) Write(database int, command []byte) error {
|
||||
// log the SELECT command before logging the incoming command.
|
||||
// This allows us to switch databases appropriately when restoring the state on startup.
|
||||
if database != store.currentDatabase {
|
||||
dbStr := strconv.Itoa(database)
|
||||
_, err := store.rw.Write([]byte(fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", len(dbStr), dbStr)))
|
||||
_, err := store.rw.Write([]byte(fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$1\r\n%s\r\n", strconv.Itoa(database))))
|
||||
if err != nil {
|
||||
return fmt.Errorf("log select error: %+v", err)
|
||||
}
|
||||
@ -238,9 +237,8 @@ func (store *Store) Truncate() error {
|
||||
}
|
||||
|
||||
// Add command to select the current database at the top of the file.
|
||||
dbStr := strconv.Itoa(store.currentDatabase)
|
||||
_, err := store.rw.Write([]byte(
|
||||
fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", len(dbStr), dbStr)))
|
||||
fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$1\r\n%s\r\n", strconv.Itoa(store.currentDatabase))))
|
||||
if err != nil {
|
||||
return fmt.Errorf("truncate: log select error: %+v", err)
|
||||
}
|
||||
|
||||
@ -351,6 +351,7 @@ func (server *SugarDB) deleteKey(ctx context.Context, key string) error {
|
||||
server.lruCache.cache[database].Delete(key)
|
||||
}
|
||||
|
||||
log.Printf("deleted key %s\n", key)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user