File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,14 @@ export default RESTAdapter.extend({
10
10
11
11
ajax : function ( url , type , options ) {
12
12
if ( type === 'GET' ) {
13
- let cache = this . fetcher . get ( url ) ;
13
+ let cache = this . fetcher . get ( url , options ) ;
14
14
if ( cache ) {
15
15
return cache ;
16
16
}
17
17
}
18
18
19
19
return this . _super ( url , type , options ) . then ( resp => {
20
- this . fetcher . put ( url , resp ) ;
20
+ this . fetcher . put ( url , options , resp ) ;
21
21
return resp ;
22
22
} ) ;
23
23
} ,
Original file line number Diff line number Diff line change @@ -6,24 +6,26 @@ const KEY = 'ajax-cache';
6
6
export default Service . extend ( {
7
7
fastboot : service ( ) ,
8
8
9
- get ( url ) {
9
+ get ( url , options ) {
10
10
let shoebox = this . fastboot . shoebox ;
11
11
if ( ! shoebox ) {
12
12
return ;
13
13
}
14
14
let cache = shoebox . retrieve ( KEY ) || { } ;
15
- return cache [ url ] ;
15
+ let key = cacheKey ( url , options ) ;
16
+ return cache [ key ] ;
16
17
} ,
17
18
18
- put ( url , obj ) {
19
+ put ( url , options , obj ) {
19
20
let fastboot = this . fastboot ;
20
21
let shoebox = this . fastboot . shoebox ;
21
22
if ( ! ( shoebox && fastboot . isFastBoot ) ) {
22
23
return ;
23
24
}
24
25
25
26
let cache = shoebox . retrieve ( KEY ) || { } ;
26
- cache [ url ] = deepCopy ( obj ) ;
27
+ let key = cacheKey ( url , options ) ;
28
+ cache [ key ] = deepCopy ( obj ) ;
27
29
shoebox . put ( KEY , cache ) ;
28
30
} ,
29
31
@@ -40,6 +42,10 @@ export default Service.extend({
40
42
} ,
41
43
} ) ;
42
44
45
+ function cacheKey ( url , options ) {
46
+ return url + JSON . stringify ( options ) ;
47
+ }
48
+
43
49
function deepCopy ( obj ) {
44
50
return JSON . parse ( JSON . stringify ( obj ) ) ;
45
51
}
You can’t perform that action at this time.
0 commit comments