const state = {}
const mutations = {
  SET_CACHE: (state, params) => {
    state = params
  },
  UPDATE_CACHE: (state, params) => {
    for (const a in params) {
      if (state[a]) {
        state[a] = Object.assign(state[a], params[a])
      } else {
        state[a] = params[a]
      }
    }
  },
  CLEAR_CACHE: (state) => {
    state = {}
  }

}

const actions = {
  updateCache({ commit }, params) {
    commit('UPDATE_CACHE', params)
  },
  setCache({ commit }, params) {
    commit('SET_CACHE', params)
  },
  clearCache({ commit }) {
    commit('CLEAR_CACHE')
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}