JSFiddle - React, Tailwind, and code Playground
HTML
<div ng-app="cacheApp">
<div ng-controller="CacheCtrl">
Data {{information()}}
</div>
</div>
JavaScript
var app = angular.module("cacheApp", [])
app.factory('myCache' , function($cacheFactory) {
return $cacheFactory('mycache' , { capacity : 3 })
});
app.controller('CacheCtrl', function($scope, myCache) {
var data = {id:10, name:"selva"};
myCache.put("nameDetails", data.name);
myCache.put("myId", data.id);
myCache.put("myId2", 20);
myCache.put("myId3", 25);
console.log("my cache =>"+myCache.get("nameDetails"));
$scope.information = function() {
return myCache.info();
};
});