MarshalBinary uses MessagePack as the encoding format to serialize the ZSetValue object into a byte array.
()
| 1220 | // MarshalBinary uses MessagePack as the encoding format to serialize |
| 1221 | // the ZSetValue object into a byte array. |
| 1222 | func (d *ZSetValue) MarshalBinary() (_ []byte, err error) { |
| 1223 | |
| 1224 | // The NewMessagePackEncoder function is called to create a new |
| 1225 | // MessagePack encoder. |
| 1226 | enc := encoding.NewMessagePackEncoder() |
| 1227 | |
| 1228 | // Then, we try to encode the 'key' field of the ZSetValue |
| 1229 | // If an error occurs, it is returned immediately along with the |
| 1230 | // currently encoded byte slice. |
| 1231 | if err = enc.Encode(d.member); err != nil { |
| 1232 | return enc.Bytes(), err |
| 1233 | } |
| 1234 | |
| 1235 | // We do the same for the 'score' field. |
| 1236 | if err = enc.Encode(d.score); err != nil { |
| 1237 | return enc.Bytes(), err |
| 1238 | } |
| 1239 | |
| 1240 | // Lastly, the 'value' field is encoded in the same way. |
| 1241 | if err = enc.Encode(d.value); err != nil { |
| 1242 | return enc.Bytes(), err |
| 1243 | } |
| 1244 | |
| 1245 | // If everything goes well and we're done encoding, we return the |
| 1246 | // final byte slice which represents the encoded ZSetValue |
| 1247 | // and a nil error. |
| 1248 | return enc.Bytes(), err |
| 1249 | } |
| 1250 | |
| 1251 | func (d *ZSetStructure) Stop() error { |
| 1252 | err := d.db.Close() |
nothing calls this directly
no test coverage detected