freecache icon indicating copy to clipboard operation
freecache copied to clipboard

GetOrSet doesn't return cache miss message

Open yintamaa opened this issue 3 years ago • 3 comments

i wanna using GetOrSet to set a empty []byte("") for protoMessage when cache miss but i have no idea how to determine cache miss, []byte("") will also make [value == nil] true

yintamaa avatar Jul 28 '22 06:07 yintamaa

You can set a single byte value like []byte{0} instead of empty []byte{}.

coocood avatar Jul 28 '22 06:07 coocood

You can set a single byte value like []byte{0} instead of empty []byte{}.

i haved also think about it,but proto.Unmarshal([]byte{0}) will get some error:invalid field number

yintamaa avatar Jul 28 '22 07:07 yintamaa

You can set a single byte value like []byte{0} instead of empty []byte{}.

i haved also think about it,but proto.Unmarshal([]byte{0}) will get some error:invalid field number

Then check the length before calling Unmarshal.

coocood avatar Jul 28 '22 07:07 coocood