在某些操作后强制 Angular 清理 $cacheFactory

Vla*_*sJS 5 angularjs cachefactory

所以我们以这种方式从下拉资源模块中的下拉列表中缓存值

var cache = new CacheFactory('DropDownResource', {
      maxAge: 3600000,
      deleteOnExpire: 'aggressive',
      capacity: 5,
      storageMode: 'sessionStorage'
    });
Run Code Online (Sandbox Code Playgroud)

然后在 $http 回调中,我们以这种方式保存下拉数据

cache.put('dataForDropDown', data);
Run Code Online (Sandbox Code Playgroud)

在其他模块中,我们可以更改用户设置,尤其是更改语言。在此操作之后,我需要清理缓存。因为当用户更改语言并转到带有下拉列表的页面时,他希望看到带有所需语言的下拉列表。

因此,在带有下拉列表的页面上,我们需要再次向服务器发送调用。为此,我们需要在语言更改后清理缓存。

我们怎么做?

我在下拉模块中尝试此代码。

var cache = $cacheFactory('dataForDropDown'); cache.remove('dataForDropDown');

但它不起作用。它说已经创建了名为 dataForDropDown 的缓存。我不明白我做错了什么