Compare commits

...

2 Commits
v0.0.1 ... main

Author SHA1 Message Date
AI Engineer
26d905517e fix(sugardb): remove noisy 'deleted key' debug log (by AI) 2026-06-28 23:21:31 +08:00
AI Engineer
7c17874b41 fix(aof): fix RESP length encoding for SELECT command database index 2026-06-28 10:33:32 +08:00
2 changed files with 5 additions and 4 deletions

View File

@ -148,7 +148,8 @@ func (store *Store) Write(database int, command []byte) error {
// log the SELECT command before logging the incoming command. // log the SELECT command before logging the incoming command.
// This allows us to switch databases appropriately when restoring the state on startup. // This allows us to switch databases appropriately when restoring the state on startup.
if database != store.currentDatabase { if database != store.currentDatabase {
_, err := store.rw.Write([]byte(fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$1\r\n%s\r\n", strconv.Itoa(database)))) 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)))
if err != nil { if err != nil {
return fmt.Errorf("log select error: %+v", err) return fmt.Errorf("log select error: %+v", err)
} }
@ -237,8 +238,9 @@ func (store *Store) Truncate() error {
} }
// Add command to select the current database at the top of the file. // Add command to select the current database at the top of the file.
dbStr := strconv.Itoa(store.currentDatabase)
_, err := store.rw.Write([]byte( _, err := store.rw.Write([]byte(
fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$1\r\n%s\r\n", strconv.Itoa(store.currentDatabase)))) fmt.Sprintf("*2\r\n$6\r\nSELECT\r\n$%d\r\n%s\r\n", len(dbStr), dbStr)))
if err != nil { if err != nil {
return fmt.Errorf("truncate: log select error: %+v", err) return fmt.Errorf("truncate: log select error: %+v", err)
} }

View File

@ -351,7 +351,6 @@ func (server *SugarDB) deleteKey(ctx context.Context, key string) error {
server.lruCache.cache[database].Delete(key) server.lruCache.cache[database].Delete(key)
} }
log.Printf("deleted key %s\n", key)
return nil return nil
} }