mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 15:20:34 +00:00
fix(repositories): in-memory cache stopped temp.
This commit is contained in:
@@ -16,6 +16,10 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
this.repositoryName = this.constructor.name;
|
this.repositoryName = this.constructor.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getByCache(key, callback) {
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the cache key of the method name and arguments.
|
* Retrieve the cache key of the method name and arguments.
|
||||||
* @param {string} method
|
* @param {string} method
|
||||||
@@ -36,7 +40,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
all(withRelations?) {
|
all(withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('all', withRelations);
|
const cacheKey = this.getCacheKey('all', withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.all(withRelations);
|
return super.all(withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -50,7 +54,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
find(attributeValues = {}, withRelations?) {
|
find(attributeValues = {}, withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('find', attributeValues, withRelations);
|
const cacheKey = this.getCacheKey('find', attributeValues, withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.find(attributeValues, withRelations);
|
return super.find(attributeValues, withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -64,7 +68,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
findWhereNot(attributeValues = {}, withRelations?) {
|
findWhereNot(attributeValues = {}, withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('findWhereNot', attributeValues, withRelations);
|
const cacheKey = this.getCacheKey('findWhereNot', attributeValues, withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.findWhereNot(attributeValues, withRelations);
|
return super.findWhereNot(attributeValues, withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -81,7 +85,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
findWhereIn(searchParam, attributeValues, withRelations?) {
|
findWhereIn(searchParam, attributeValues, withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('findWhereIn', attributeValues, withRelations);
|
const cacheKey = this.getCacheKey('findWhereIn', attributeValues, withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.findWhereIn(searchParam, attributeValues, withRelations);
|
return super.findWhereIn(searchParam, attributeValues, withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -96,7 +100,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
findOne(attributeValues = {}, withRelations?) {
|
findOne(attributeValues = {}, withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('findOne', attributeValues, withRelations);
|
const cacheKey = this.getCacheKey('findOne', attributeValues, withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.findOne(attributeValues, withRelations);
|
return super.findOne(attributeValues, withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -111,7 +115,7 @@ export default class CachableRepository extends EntityRepository{
|
|||||||
findOneById(id, withRelations?) {
|
findOneById(id, withRelations?) {
|
||||||
const cacheKey = this.getCacheKey('findOneById', id, withRelations);
|
const cacheKey = this.getCacheKey('findOneById', id, withRelations);
|
||||||
|
|
||||||
return this.cache.get(cacheKey, () => {
|
return this.getByCache(cacheKey, () => {
|
||||||
return super.findOneById(id, withRelations);
|
return super.findOneById(id, withRelations);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user