Set stores the given value for the given key. Values are automatically marshalled to JSON or gob (depending on the configuration). The key must not be "" and the value must not be nil.
(k string, v any)
| 26 | // Values are automatically marshalled to JSON or gob (depending on the configuration). |
| 27 | // The key must not be "" and the value must not be nil. |
| 28 | func (c Client) Set(k string, v any) error { |
| 29 | if err := util.CheckKeyAndValue(k, v); err != nil { |
| 30 | return err |
| 31 | } |
| 32 | |
| 33 | // First turn the passed object into something that S3 can handle. |
| 34 | data, err := c.codec.Marshal(v) |
| 35 | if err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | pubObjectInput := awss3.PutObjectInput{ |
| 40 | Body: bytes.NewReader(data), |
| 41 | Bucket: &c.bucketName, |
| 42 | Key: &k, |
| 43 | } |
| 44 | _, err = c.c.PutObject(&pubObjectInput) |
| 45 | if err != nil { |
| 46 | return err |
| 47 | } |
| 48 | |
| 49 | return nil |
| 50 | } |
| 51 | |
| 52 | // Get retrieves the stored value for the given key. |
| 53 | // You need to pass a pointer to the value, so in case of a struct |
no outgoing calls