func (d *DiskStorage) Put(key string, value interface{}) error {
	data, err := d.serializer(value)
	if err != nil {
		return err
	}
	err = d.db.Update(func(tx *bolt.Tx) error {
		b := tx.Bucket([]byte(d.name))
		return b.Put([]byte(key), data)
	})
	if err != nil {
		return err
	}
	return d.memory.Put(key, value)
}
Put somethings into disk storage
package storage
import (
	"errors"
	"sync"
	"github.com/AliyunContainerService/terway/pkg/logger"
	"github.com/boltdb/bolt"
)
var log = logger.DefaultLogger.WithField("subSys", "storage")
var ErrNotFound = errors.New("not found")
type Storage interface {
	Put(key string, value interface{}) error
	Get(key string) (interface{}, error)
	List() ([]interface{}, error)
	Delete(key string) error
}
type MemoryStorage struct {
	lock  sync.RWMutex
	store map[string]interface{}
}
func NewMemoryStorage() *MemoryStorage {
	return &MemoryStorage{
		store: make(map[string]interface{}),
	}
}
func (m *MemoryStorage) Put(key string, value interface{}) error {
	m.lock.Lock()
	defer m.lock.Unlock()
	m.store[key] = value
	return nil
}
func (m *MemoryStorage) Get(key string) (interface{}, error) {
	m.lock.RLock()
	defer m.lock.RUnlock()
	value, ok := m.store[key]
	if !ok {
		return nil, ErrNotFound
	}
	return value, nil
}
func (m *MemoryStorage) List() ([]interface{}, error) {
	m.lock.RLock()
	defer m.lock.RUnlock()
	var ret []interface{}
	for _, v := range m.store {
		ret = append(ret, v)
	}
	return ret, nil
}
func (m *MemoryStorage) Delete(key string) error {
	m.lock.Lock()
	defer m.lock.Unlock()
	delete(m.store, key)
	return nil
}
type Serializer func(interface{}) ([]byte, error)
type Deserializer func([]byte) (interface{}, error)
type DiskStorage struct {
	db           *bolt.DB
	name         string
	memory       *MemoryStorage
	serializer   Serializer
	deserializer Deserializer
}
func NewDiskStorage(name string, path string, serializer Serializer, deserializer Deserializer) (Storage, error) {
	db, err := bolt.Open(path, 0600, nil)
	if err != nil {
		return nil, err
	}
	diskstorage := &DiskStorage{
		db:           db,
		name:         name,
		memory:       NewMemoryStorage(),
		serializer:   serializer,
		deserializer: deserializer,
	}
	err = diskstorage.load()
	if err != nil {
		return nil, err
	}
	return diskstorage, nil
}