|
@@ -32,25 +32,25 @@ func (c *ttlCache) Get(elm Element) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-func (c *ttlCache) Set(items ...Element) {
|
|
|
+func (c *ttlCache) Set(items ...Element) error {
|
|
|
if items == nil {
|
|
|
- return
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
- go func() {
|
|
|
- for _, item := range items {
|
|
|
- if item == nil {
|
|
|
- continue
|
|
|
- }
|
|
|
-
|
|
|
- buf, err := item.Marshal()
|
|
|
- if err != nil {
|
|
|
- continue
|
|
|
- }
|
|
|
+ for _, item := range items {
|
|
|
+ if item == nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
|
|
|
- c.buf.Add(item.Key(), buf)
|
|
|
+ buf, err := item.Marshal()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
}
|
|
|
- }()
|
|
|
+
|
|
|
+ c.buf.Add(item.Key(), buf)
|
|
|
+ }
|
|
|
+
|
|
|
+ return nil
|
|
|
}
|
|
|
|
|
|
func (c *ttlCache) String() string {
|