'Set the specified preference to the specified value. See also :meth:`pref`.'

@write_api
def set_pref(self, name, val):

    self.backend.prefs.set(name, val)
    if (name == u'grouped_search_terms'):
        self._clear_search_caches()
    if (name in dynamic_category_preferences):
        self._initialize_dynamic_categories()
