This repository has been archived by the owner on Apr 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vps): add cache for available images queries (#237)
ref: MANAGER-3074
- Loading branch information
1 parent
b9307c6
commit 58ece3e
Showing
1 changed file
with
26 additions
and
6 deletions.
There are no files selected for viewing
32 changes: 26 additions & 6 deletions
32
src/api/vps/images/available/vps-images-available.v6.service.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
angular.module('ovh-api-services').service('OvhApiVpsImagesAvailableV6', $resource => $resource('/vps/:serviceName/images/available', { | ||
serviceName: '@serviceName', | ||
}, { | ||
query: { method: 'GET', isArray: true }, | ||
get: { method: 'GET', url: '/vps/:serviceName/images/available/:id' }, | ||
})); | ||
angular.module('ovh-api-services').service('OvhApiVpsImagesAvailableV6', ($cacheFactory, $resource) => { | ||
const cache = $cacheFactory('OvhApiVpsImagesAvailableV6'); | ||
const queryCache = $cacheFactory('OvhApiVpsImagesAvailableV6'); | ||
|
||
const resource = $resource('/vps/:serviceName/images/available', { | ||
serviceName: '@serviceName', | ||
}, { | ||
query: { method: 'GET', isArray: true, cache: queryCache }, | ||
get: { method: 'GET', url: '/vps/:serviceName/images/available/:id', cache }, | ||
}); | ||
|
||
resource.resetCache = () => { | ||
cache.removeAll(); | ||
}; | ||
|
||
resource.resetQueryCache = () => { | ||
queryCache.removeAll(); | ||
}; | ||
|
||
resource.resetAllCache = () => { | ||
resource.resetCache(); | ||
resource.resetQueryCache(); | ||
}; | ||
|
||
return resource; | ||
}); |