type $cacheFactory.Cache

用于存储和检索数据的缓存对象,主要用于http和scipt指令,用于缓存模板和其他数据。

用法:

index.html

<!DOCTYPE html>
<html ng-app="indexApp">
<head lang="en">
    <meta charset="UTF-8">
    <title>BookStore</title>
</head>
<body  ng-controller="firCtrl">
<div>
    <label>msg:<input ng-model="msg" /></label>
    <label>id:<input ng-model="msg.id" /></label>
    <label>size:<input ng-model="msg.size" /></label>
</div>
<script src="framework/angular.js"></script>
<script src="myJs/cache.js"></script>
<script src="myJs/index.js"></script>
</body>
</html>

index.js

angular.module(‘indexApp‘,["superCache"])
    .controller(‘firCtrl‘,[‘$scope‘, ‘smCache‘ ,function($scope, smCache){
        smCache.put("name","drr");
        smCache.put("how","like");
        $scope.msg = smCache.info();
}]);

cache.js

angular.module(‘superCache‘,[])
.factory(‘smCache‘,[‘$cacheFactory‘,function($cacheFactory){
    return $cacheFactory(‘ms‘);
}]);

方法:

put(key, value);

get(key);

remove(key);

remove(key);

destroy();

info(); 返回具有以下属性的对象:id:缓存实例的id,size::缓存实例中保存的条目的数量...在创建缓存时,选项对象中的任何其他属性。

时间: 2024-08-02 19:11:44

type $cacheFactory.Cache的相关文章

基于Senparc.CO2NET 缓存策略扩展的缓存使用方法

没啥说的,直接上代码 1.缓存  CacheFactory 实现: //----------------------------------------------------------------------- // <copyright file="CacheFactory.cs" company="FenSiShengHuo, Ltd."> // Copyright (c) 2018 , All rights reserved. // </

angular源码剖析之Provider系列--CacheFactoryProvider

CacheFactoryProvider 简介 源码里是这么描述的: Factory that constructs {@link $cacheFactory.Cache Cache} objects and gives access to them. 意思就是通过cacheFactory可以构造一个Cache对象来给予访问和执行权限. 这个Cache对象官方文档是这么说的: A cache object used to store and retrieve data, primarily us

[AngularJS] $http cache

By default your HTTP requests with the $https service in Angular are not cached. By setting some options, you can turn caching on. /** * Created by Answer1215 on 12/15/2014. */ angular.module('app', ['ngMaterial']) .controller('MainCtrl', function(Bo

微软企业库的Cache

微软企业库的Cache 通常,应用程序可以将那些频繁访问的数据,以及那些需要大量处理时间来创建的数据存储在内存中,从而提高性能.基于微软的企业库,我们的快速创建一个缓存的实现. 新建PrismSample.Infrastructure.Cache 新建一个类库项目,将其命名为PrismSample.Infrastructure.Cache,然后从nuget中下载微软企业库的Cache. 然后新建我们的CacheManager类: using Microsoft.Practices.Enterpr

【转载】Java Cache系列之Cache概述和Simple Cache

原文地址:http://www.blogjava.net/DLevin/archive/2013/10/15/404770.html 前记:最近公司在做的项目完全基于Cache(Gemfire)构建了一个类数据库的系统,自己做的一个小项目里用过Guava的Cache,以前做过的项目中使用过EHCache,既然和Cache那么有缘,那就趁这个机会好好研究一下Java中的Cache库.在Java社区中已经提供了很多Cache库实现,具体可以参考http://www.open-open.com/13.

Angularjs 常用服务 $http $location $anchorScroll $cacheFactory $timeout $interval $sce

Angularjs 常用服务 $http $location$anchorScroll $cacheFactory $timeout $interval $sce学习要点:1. Angularjs 中的 $http 服务2. Angularjs 中的 $location $anchorScroll 服务3. Angularjs 中的 $cacheFactory 服务4. Angularjs 中的 $timeout $interval 服务5. $sce 服务 浏览器简析 html 标签1. An

angular中$cacheFactory缓存的使用

最近在学习使用angular,慢慢从jquery ui转型到用ng开发,发现了很多不同点,继续学习吧: 首先创建一个服务,以便在项目中的controller中引用,服务有几种存在形式,factory();service();constant();value();provider();其中provider是最基础的,其他服务都是基于这个写的,具体区别这里就不展开了,大家可以看看源码:服务是各个controller之间通话的重要形式,在实际项目中会用的很多,下面是代码: angular.module

Cache应用/任务Mutex,用于高并发任务处理经过多个项目使用

<?php /** * Class Cache redis 用于报表的缓存基本存储和读写 2.0 * <pre> * Cache::read("diamond.account",$nick); * Cache::readSync("diamond.account",$nick); * $finder = Cache::createFinder("diamond.account",$nick); * $finder->rea

dubbo如何做cache缓存

duubo如何使用cache的?CacheFilterclass里面有,这个filter既可以在provider也可以在consumerif (cacheFactory != null && ConfigUtils.isNotEmpty(invoker.getUrl().getMethodParameter(invocation.getMethodName(), Constants.CACHE_KEY))) {可见只要对方法url加了cache标志,就会使用cache,通过cacheFac