Skip to content

Commit de2368c

Browse files
committed
Revised angular-cache documentation.
1 parent 72aa868 commit de2368c

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

guide/angular-cache/basics.doc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
@description
55

66
## Create a cache
7-
First, inject `$angularCacheFactory` then create as many caches as you so desire. Let's go:
7+
First, inject `DSCacheFactory` then create as many caches as you so desire. Let's go:
88

99
```javascript
10-
app.service('myService', function ($angularCacheFactory) {
10+
app.service('myService', function (DSCacheFactory) {
1111

1212
// Create a new cache called "profileCache"
13-
var profileCache = $angularCacheFactory('profileCache');
13+
var profileCache = DSCacheFactory('profileCache');
1414
});
1515
```
1616

@@ -61,7 +61,7 @@ profileCache.setOptions({
6161
Sweet! Now we'd probably have configured our cache correctly when we created it:
6262

6363
```javascript
64-
var profileCache = $angularCacheFactory('profileCache', {
64+
var profileCache = DSCacheFactory('profileCache', {
6565
maxAge: 3600000,
6666
deleteOnExpire: 'aggressive',
6767
onExpire: function (key, value) {
@@ -75,10 +75,10 @@ var profileCache = $angularCacheFactory('profileCache', {
7575
Or say we want all of our caches to use that configuration as their default:
7676

7777
```javascript
78-
angular.module('app', ['jmdobry.angular-cache'])
79-
.config(function ($angularCacheFactoryProvider) {
78+
angular.module('app', ['angular-data.DSCacheFactory'])
79+
.config(function (DSCacheFactoryProvider) {
8080

81-
$angularCacheFactoryProvider.setCacheDefaults({
81+
DSCacheFactoryProvider.setCacheDefaults({
8282
maxAge: 3600000,
8383
deleteOnExpire: 'aggressive',
8484
onExpire: function (key, value) {
@@ -128,7 +128,7 @@ profileCache.get('/profiles/34'); // undefined
128128

129129
profileCache.destroy();
130130

131-
$angularCacheFactory.get('profileCache'); // undefined
131+
DSCacheFactory.get('profileCache'); // undefined
132132
```
133133

134-
See the [API Documentation](api.html) for more information on the available methods.
134+
See the [API Documentation](/documentation/api/angular-cache/angular-cache) for more information on the available methods.

guide/angular-cache/configure.doc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
@name Configure a cache
44
@description
55

6-
See [Configuration Options](configuration.html) for information on the available configuration options.
6+
See the [API Documentation](/documentation/api/angular-cache/angular-cache) for information on the available configuration options.
77

88
#### Dynamically configure a cache
99
```javascript
10-
app.service('myService', function ($angularCacheFactory) {
10+
app.service('myService', function (DSCacheFactory) {
1111

12-
var cache = $angularCacheFactory('cache', {
12+
var cache = DSCacheFactory('cache', {
1313
capacity: 100,
1414
maxAge: 300000
1515
});
@@ -40,4 +40,4 @@ app.service('myService', function ($angularCacheFactory) {
4040
cache.info('someItem'); // { maxAge: 12000, deleteOnExpire: 'aggressive', isExpired: false, ... }
4141
});
4242
```
43-
See [AngularCache.setOptions(options)](api.html#cachesetoptions).
43+
See the [API Documentation](/documentation/api/angular-cache/angular-cache) for more information.

guide/angular-cache/http.doc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
__Note__ The downside of letting $http handle caching for you is that it caches the responses (in string form) to your requests–not the JavaScript Object parsed from the response body. This means you can't interact with the data in the cache used by `$http`. See below for how to handle the caching yourself–giving you more control and the ability to interact with the cache (use it as a data store).
99

10-
Configure `$http` to use a cache created by `$angularCacheFactory` by default:
10+
Configure `$http` to use a cache created by `DSCacheFactory` by default:
1111
```javascript
12-
app.run(function ($http, $angularCacheFactory) {
12+
app.run(function ($http, DSCacheFactory) {
1313

14-
$angularCacheFactory('defaultCache', {
14+
DSCacheFactory('defaultCache', {
1515
maxAge: 900000, // Items added to this cache expire after 15 minutes.
1616
cacheFlushInterval: 6000000, // This cache will clear itself every hour.
1717
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
1818
});
1919

20-
$http.defaults.cache = $angularCacheFactory.get('defaultCache');
20+
$http.defaults.cache = DSCacheFactory.get('defaultCache');
2121
});
2222

2323
app.service('myService', function ($http) {
@@ -50,11 +50,11 @@ app.controller('myCtrl', function (myService) {
5050
});
5151
```
5252

53-
Tell `$http` to use a cache created by `$angularCacheFactory` for a specific request:
53+
Tell `$http` to use a cache created by `DSCacheFactory` for a specific request:
5454
```javascript
55-
app.service('myService', function ($http, $angularCacheFactory) {
55+
app.service('myService', function ($http, DSCacheFactory) {
5656

57-
$angularCacheFactory('dataCache', {
57+
DSCacheFactory('dataCache', {
5858
maxAge: 90000, // Items added to this cache expire after 15 minutes.
5959
cacheFlushInterval: 600000, // This cache will clear itself every hour.
6060
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
@@ -66,7 +66,7 @@ app.service('myService', function ($http, $angularCacheFactory) {
6666
start = new Date().getTime();
6767

6868
$http.get('api/data/' + id, {
69-
cache: $angularCacheFactory.get('dataCache')
69+
cache: DSCacheFactory.get('dataCache')
7070
}).success(function (data) {
7171
console.log('time taken for request: ' + (new Date().getTime() - start) + 'ms');
7272
deferred.resolve(data);
@@ -91,9 +91,9 @@ app.controller('myCtrl', function (myService) {
9191

9292
Do your own caching while using the $http service:
9393
```javascript
94-
app.service('myService', function ($http, $angularCacheFactory) {
94+
app.service('myService', function ($http, DSCacheFactory) {
9595

96-
$angularCacheFactory('dataCache', {
96+
DSCacheFactory('dataCache', {
9797
maxAge: 900000, // Items added to this cache expire after 15 minutes.
9898
cacheFlushInterval: 3600000, // This cache will clear itself every hour.
9999
deleteOnExpire: 'aggressive' // Items will be deleted from this cache right when they expire.
@@ -103,7 +103,7 @@ app.service('myService', function ($http, $angularCacheFactory) {
103103
getDataById: function (id) {
104104
var deferred = $q.defer(),
105105
start = new Date().getTime(),
106-
dataCache = $angularCacheFactory.get('dataCache');
106+
dataCache = DSCacheFactory.get('dataCache');
107107

108108
// Now that control of inserting/removing from the cache is in our hands,
109109
// we can interact with the data in "dataCache" outside of this context,

guide/angular-cache/storage.doc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
#### Using angular-cache with localStorage (or sessionStorage)
77
Using angular-cache in browsers that support localStorage:
88
```javascript
9-
app.service('myService', function ($angularCacheFactory) {
9+
app.service('myService', function (DSCacheFactory) {
1010

1111
// This cache will sync itself with localStorage if it exists, otherwise it won't. Every time the
1212
// browser loads this app, this cache will attempt to initialize itself with any data it had
1313
// already saved to localStorage (or sessionStorage if you used that).
14-
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
14+
var myAwesomeCache = DSCacheFactory('myAwesomeCache', {
1515
maxAge: 900000, // Items added to this cache expire after 15 minutes.
1616
cacheFlushInterval: 3600000, // This cache will clear itself every hour.
1717
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
@@ -28,7 +28,7 @@ Option 2 - Create/use a polyfill that provides the global `localStorage` and `se
2828

2929
Option 3 - Tell angular-cache exactly which polyfill to use (also useful if you just want to use your own implementation/wrapper for localStorage):
3030
```javascript
31-
app.service('myService', function ($angularCacheFactory) {
31+
app.service('myService', function (DSCacheFactory) {
3232

3333
var localStoragePolyfill = {
3434
getItem: function (key) { ... },
@@ -37,7 +37,7 @@ app.service('myService', function ($angularCacheFactory) {
3737
};
3838

3939
// Always use the polyfill
40-
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', {
40+
var myAwesomeCache = DSCacheFactory('myAwesomeCache', {
4141
maxAge: 900000, // Items added to this cache expire after 15 minutes.
4242
cacheFlushInterval: 3600000, // This cache will clear itself every hour.
4343
deleteOnExpire: 'aggressive', // Items will be deleted from this cache right when they expire.
@@ -55,7 +55,7 @@ app.service('myService', function ($angularCacheFactory) {
5555
if (!window.localStorage) {
5656
options.storageImpl = localStoragePolyfill;
5757
}
58-
var myAwesomeCache = $angularCacheFactory('myAwesomeCache', options);
58+
var myAwesomeCache = DSCacheFactory('myAwesomeCache', options);
5959
});
6060
```
6161

@@ -84,7 +84,7 @@ var storeJsToStandard {
8484
removeItem: store.remove
8585
};
8686

87-
$angularCacheFactory('myNewCache', {
87+
DSCacheFactory('myNewCache', {
8888
storageMode: 'localStorage',
8989
storageImpl: storeJsToStandard
9090
});

0 commit comments

Comments
 (0)