You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: store.rb
    path of file: ./repos/openfoodnetwork/app/models/spree/preferences
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# Use singleton class Spree::Preferences::Store.in
    
      def persist(cache_key, value, type)
        return unless should_persist?

        preference = Spree::Preference.where(key: cache_key).first_or_initialize
        preference.value = value
        preference.value_type = type
        preference.save
      end