MCPcopy Index your code
hub / github.com/HDT3213/rdb / writeString

Method writeString

core/string.go:279–296  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

277}
278
279func (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
299func (enc *Encoder) writeNanString(s string) error {

Callers 15

writeSetEncodingMethod · 0.95
writeHashEncodingMethod · 0.95
writeHashEncodingExMethod · 0.95
writeHash2EncodingMethod · 0.95
TestStringEncodingFunction · 0.95
TestRandomStringEncodingFunction · 0.95
WriteStringObjectMethod · 0.95
WriteAuxMethod · 0.95
writeZSet2EncodingMethod · 0.95
tryWriteZipListZSetMethod · 0.95

Calls 3

tryWriteIntStringMethod · 0.95
writeLZFStringMethod · 0.95
writeSimpleStringMethod · 0.95

Tested by 4

TestStringEncodingFunction · 0.76
TestRandomStringEncodingFunction · 0.76
TestModuleTypeFunction · 0.76
TestLZFStringFunction · 0.64