@@ -7,13 +7,13 @@ import { PathBuilder } from './services/path-builder';
77import { UrlParamsBuilder } from './services/url-params-builder' ;
88import { Converter } from './services/converter' ;
99import { LocalFilter } from './services/localfilter' ;
10- import { MemoryCache } from './services/memorycache ' ;
10+ import { CacheMemory } from './services/cachememory ' ;
1111
1212import { IService , ISchema , IResource , ICollection , IExecParams , ICache , IParamsCollection , IParamsResource } from './interfaces' ;
1313
1414export class Service extends ParentResourceService implements IService {
1515 public schema : ISchema ;
16- public memorycache : ICache ;
16+ public cachememory : ICache ;
1717 public type : string ;
1818
1919 private path : string ; // without slashes
@@ -28,7 +28,7 @@ export class Service extends ParentResourceService implements IService {
2828 throw 'Error: you are trying register --> ' + this . type + ' <-- before inject JsonapiCore somewhere, almost one time.' ;
2929 }
3030 // only when service is registered, not cloned object
31- this . memorycache = new MemoryCache ( ) ;
31+ this . cachememory = new CacheMemory ( ) ;
3232 this . schema = angular . extend ( { } , Base . Schema , this . schema ) ;
3333 return Core . me . _register ( this ) ;
3434 }
@@ -79,17 +79,17 @@ export class Service extends ParentResourceService implements IService {
7979 path . appendPath ( id ) ;
8080
8181 // cache
82- let resource = this . getService ( ) . memorycache . getOrCreateResource ( this . type , id , true ) ;
82+ let resource = this . getService ( ) . cachememory . getOrCreateResource ( this . type , id , true ) ;
8383 resource . is_loading = true ;
8484 // exit if ttl is not expired
8585 let temporal_ttl = params . ttl ? params . ttl : 0 ;
86- if ( this . getService ( ) . memorycache . isResourceLive ( id , temporal_ttl ) ) {
86+ if ( this . getService ( ) . cachememory . isResourceLive ( id , temporal_ttl ) ) {
8787 // we create a promise because we need return collection before
8888 // run success client function
8989 var deferred = Core . injectedServices . $q . defer ( ) ;
9090 deferred . resolve ( fc_success ) ;
9191 deferred . promise . then ( fc_success => {
92- this . runFc ( fc_success , 'memorycache ' ) ;
92+ this . runFc ( fc_success , 'cachememory ' ) ;
9393 } ) ;
9494 resource . is_loading = false ;
9595 return resource ;
@@ -102,7 +102,7 @@ export class Service extends ParentResourceService implements IService {
102102 success => {
103103 Converter . build ( success . data , resource ) ;
104104 resource . is_loading = false ;
105- this . getService ( ) . memorycache . setResource ( resource ) ;
105+ this . getService ( ) . cachememory . setResource ( resource ) ;
106106 this . runFc ( fc_success , success ) ;
107107 } ,
108108 error => {
@@ -134,13 +134,13 @@ export class Service extends ParentResourceService implements IService {
134134
135135 // make request
136136 // if we remove this, dont work the same .all on same time (ej: <component /><component /><component />)
137- let tempororay_collection = this . getService ( ) . memorycache . getOrCreateCollection ( path . getForCache ( ) , true ) ;
137+ let tempororay_collection = this . getService ( ) . cachememory . getOrCreateCollection ( path . getForCache ( ) , true ) ;
138138
139139 // MEMORY_CACHE
140140 let temporal_ttl = params . ttl ? params . ttl : this . schema . ttl ;
141- if ( temporal_ttl >= 0 && this . getService ( ) . memorycache . isCollectionExist ( path . getForCache ( ) ) ) {
141+ if ( temporal_ttl >= 0 && this . getService ( ) . cachememory . isCollectionExist ( path . getForCache ( ) ) ) {
142142 // get cached data and merge with temporal collection
143- tempororay_collection . $source = 'memorycache ' ;
143+ tempororay_collection . $source = 'cachememory ' ;
144144
145145 // check smartfiltertype, and set on localfilter
146146 if ( params . smartfilter && this . smartfiltertype === 'localfilter' ) {
@@ -152,13 +152,13 @@ export class Service extends ParentResourceService implements IService {
152152 tempororay_collection = localfilter . filterCollection ( tempororay_collection , params . localfilter ) ;
153153
154154 // exit if ttl is not expired
155- if ( this . getService ( ) . memorycache . isCollectionLive ( path . getForCache ( ) , temporal_ttl ) ) {
155+ if ( this . getService ( ) . cachememory . isCollectionLive ( path . getForCache ( ) , temporal_ttl ) ) {
156156 // we create a promise because we need return collection before
157157 // run success client function
158158 var deferred = Core . injectedServices . $q . defer ( ) ;
159159 deferred . resolve ( fc_success ) ;
160160 deferred . promise . then ( fc_success => {
161- this . runFc ( fc_success , 'memorycache ' ) ;
161+ this . runFc ( fc_success , 'cachememory ' ) ;
162162 } ) ;
163163 return tempororay_collection ;
164164 }
@@ -207,7 +207,7 @@ export class Service extends ParentResourceService implements IService {
207207
208208 Converter . build ( success . data , tempororay_collection ) ;
209209
210- this . getService ( ) . memorycache . setCollection ( path . getForCache ( ) , tempororay_collection ) ;
210+ this . getService ( ) . cachememory . setCollection ( path . getForCache ( ) , tempororay_collection ) ;
211211
212212 if ( params . storage_ttl > 0 ) {
213213 Core . injectedServices . JsonapiHttpStorage . save ( path . getForCache ( ) , success . data ) ;
@@ -247,7 +247,7 @@ export class Service extends ParentResourceService implements IService {
247247 . delete ( path . get ( ) )
248248 . then (
249249 success => {
250- this . getService ( ) . memorycache . removeResource ( id ) ;
250+ this . getService ( ) . cachememory . removeResource ( id ) ;
251251 this . runFc ( fc_success , success ) ;
252252 } ,
253253 error => {
@@ -263,7 +263,7 @@ export class Service extends ParentResourceService implements IService {
263263 return < T > Converter . getService ( this . type ) ;
264264 }
265265
266- public clearMemoryCache ( ) : boolean {
267- return this . getService ( ) . memorycache . clearAllCollections ( ) ;
266+ public clearCacheMemory ( ) : boolean {
267+ return this . getService ( ) . cachememory . clearAllCollections ( ) ;
268268 }
269269}
0 commit comments