| 277 | } |
| 278 | |
| 279 | func (enc *Encoder) writeString(s string) error { |
| 280 | isInt, err := enc.tryWriteIntString(s) |
| 281 | if err != nil { |
| 282 | return err |
| 283 | } |
| 284 | if isInt { |
| 285 | return nil |
| 286 | } |
| 287 | // Try LZF compression - under 20 bytes it's unable to compress even so skip it |
| 288 | // see rdbSaveRawString at [rdb.c](https://github.com/redis/redis/blob/unstable/src/rdb.c#L449) |
| 289 | if enc.compress && len(s) > 20 { |
| 290 | err = enc.writeLZFString(s) |
| 291 | if err == nil { // lzf may failed, while out > in |
| 292 | return nil |
| 293 | } |
| 294 | } |
| 295 | return enc.writeSimpleString(s) |
| 296 | } |
| 297 | |
| 298 | // write string without try int string. for tryWriteIntSetEncoding, writeZipList |
| 299 | func (enc *Encoder) writeNanString(s string) error { |