| 110 | } |
| 111 | |
| 112 | func (db *DB) validateKeyValue(key, value []byte) error { |
| 113 | if len(key) == 0 { |
| 114 | return fmt.Errorf("key cannot be empty") |
| 115 | } |
| 116 | if int64(len(key)) > db.config.MaxKeySize { |
| 117 | return fmt.Errorf("key size %d exceeds maximum allowed %d", len(key), db.config.MaxKeySize) |
| 118 | } |
| 119 | if int64(len(value)) > db.config.MaxValueSize { |
| 120 | return fmt.Errorf("value size %d exceeds maximum allowed %d", len(value), db.config.MaxValueSize) |
| 121 | } |
| 122 | return nil |
| 123 | } |
| 124 | |
| 125 | func copyBytes(b []byte) []byte { |
| 126 | if b == nil { |