如何创建从缓存中最近的项目列表? [英] How to create a list of recent items from cache?

查看:116
本文介绍了如何创建从缓存中最近的项目列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个移动SPA应用程序,使用AngularJS和微风。

I am making a mobile SPA application, using AngularJS and Breeze.

此应用程序的用户将能够观看一些项目,我希望应用程序记住用户观看什么项目和频率。从这个信息,我希望能够创造出最喜欢的物品或最新的资料的清单。

The users of this application are going to be able to watch some items and I want the application to remember what items the user has watched and how often. From this information I want to be able to create a list of "favorite items" or "Recent items".

我不是想保存此信息到后端。我想保存在浏览器缓存此信息 - 直到浏览器的缓存在一段时间清零

I am NOT thinking of saving this information to the back-end. I want this information saved in browser cache - until the browser cache is cleared at some time.

我会怎么做呢?

饼干?

请问角或微风有东西帮我实现这一目标?

Does Angular or Breeze have something to help me achieve this?

推荐答案

在一般情况下,你可以在内存中缓存或本地存储使用。真的有很好的角度的插件,使得使用这些非常简单的:

In general, you can use in memory cache or a local storage. There are really very good angular plugins, making the use of these very simple:

  • Angular cache
  • Local storage

该角缓存有类似的方法API:

The Angular cache has API with methods like:

.get(key)
.put(key, value)
.clearAll()

在这里阅读更多 http://jmdobry.github.io/angular-cache/api html的

本地存储也有类似

.get(key)
.add(key, value)
.clearAll()

在这里阅读更多 http://gregpike.net/demos/angular - 本地存储/演示/ demo.html

另外这个博客帖子功率高达角的$ HTTP服务与缓存提供了很好的概述。

Also this blog post Power up Angular's $http service with caching provides nice overview.

最有意思的是,这两个概念,甚至可以一起工作,即得。一些缓存的东西(在内存中)也可以被放置到本地存储......晚些时候,请检查:

The most interesting is, that these two concepts can even work together, ie. some cached stuff (in memory) could also be placed into local storage ... available later, please check:

  • How can I use angular-cache in conjunction with the AngularJS LocalStorageModule
  • When using angular-cache is there any advantage to using the Angular LocalStorageModule?

摘要:在角缓存本地存储插件提供在客户端上使用缓存interection非常好的,简单的API

Summary: the Angular-cache and the Local-storage plugins provide the very nice and simple API for interection with the cache on the client

这篇关于如何创建从缓存中最近的项目列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆