Skip to content
This repository has been archived by the owner on Apr 3, 2023. It is now read-only.

Commit

Permalink
feat(vps): add cache for available images queries (#237)
Browse files Browse the repository at this point in the history
ref: MANAGER-3074
  • Loading branch information
JeremyDec authored and antleblanc committed Sep 30, 2019
1 parent b9307c6 commit 58ece3e
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/api/vps/images/available/vps-images-available.v6.service.js
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;
});

0 comments on commit 58ece3e

Please sign in to comment.