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