func (db *Db) DeleteFile() error {
	return DeleteFile(db.name)
}
DeleteFile close and delete file
package pudge
import (
	"bytes"
	"encoding/gob"
	"os"
)
var DefaultConfig = &Config{
	FileMode:     0644,
	DirMode:      0755,
	SyncInterval: 0,
	StoreMode:    0}
func Open(f string, cfg *Config) (*Db, error) {
	if cfg == nil {
		cfg = DefaultConfig
	}
	dbs.RLock()
	db, ok := dbs.dbs[f]
	if ok {
		dbs.RUnlock()
		return db, nil
	}
	dbs.RUnlock()
	dbs.Lock()
	db, err := newDb(f, cfg)
	if err == nil {
		dbs.dbs[f] = db
	}
	dbs.Unlock()
	return db, err
}
func (db *Db) Set(key, value interface{}) error {
	db.Lock()
	defer db.Unlock()
	k, err := KeyToBinary(key)
	if err != nil {
		return err
	}
	v, err := ValToBinary(value)
	if err != nil {
		return err
	}
	oldCmd, exists := db.vals[string(k)]
	if db.storemode == 2 {
		cmd := &Cmd{}
		cmd.Size = uint32(len(v))
		cmd.Val = make([]byte, len(v))
		copy(cmd.Val, v)
		db.vals[string(k)] = cmd
	} else {
		cmd, err := writeKeyVal(db.fk, db.fv, k, v, exists, oldCmd)
		if err != nil {
			return err
		}
		db.vals[string(k)] = cmd
	}
	if !exists {
		db.appendKey(k)
	}
	return err
}
func (db *Db) Get(key, value interface{}) error {
	db.RLock()
	defer db.RUnlock()
	k, err := KeyToBinary(key)
	if err != nil {
		return err
	}
	if val, ok := db.vals[string(k)]; ok {
		switch value.(type) {
		case *[]byte:
			b := make([]byte, val.Size)
			if db.storemode == 2 {
				copy(b, val.Val)
			} else {
				_, err := db.fv.ReadAt(b, int64(val.Seek))
				if err != nil {
					return err
				}
			}
			*value.(*[]byte) = b
			return nil
		default:
			buf := new(bytes.Buffer)
			b := make([]byte, val.Size)
			if db.storemode == 2 {
				copy(b, val.Val)
			} else {
				_, err := db.fv.ReadAt(b, int64(val.Seek))
				if err != nil {
					return err
				}
			}
			buf.Write(b)
			err = gob.NewDecoder(buf).Decode(value)
			return err
		}
	}
	return ErrKeyNotFound
}
func (db *Db) Close() error {
	if db.cancelSyncer != nil {
		db.cancelSyncer()
	}
	db.Lock()
	defer db.Unlock()
	if db.storemode == 2 && db.name != "" {
		db.sort()
		keys := make([][]byte, len(db.keys))
		copy(keys, db.keys)
		db.storemode = 0
		for _, k := range keys {
			if val, ok := db.vals[string(k)]; ok {
				writeKeyVal(db.fk, db.fv, k, val.Val, false, nil)
			}
		}
	}
	if db.fk != nil {
		err := db.fk.Sync()
		if err != nil {
			return err
		}
		err = db.fk.Close()
		if err != nil {
			return err
		}
	}
	if db.fv != nil {
		err := db.fv.Sync()
		if err != nil {
			return err
		}
		err = db.fv.Close()
		if err != nil {
			return err
		}
	}
	dbs.Lock()
	delete(dbs.dbs, db.name)
	dbs.Unlock()
	return nil
}
func CloseAll() (err error) {
	dbs.Lock()
	stores := dbs.dbs
	dbs.Unlock()
	for _, db := range stores {
		err = db.Close()
		if err != nil {
			break
		}
	}
	return err
}