fix: CacheAdapter does not connect when using a CacheAdapter with a JSON config (#8633)
This commit is contained in:
@@ -167,4 +167,18 @@ describe_only(() => {
|
|||||||
.then(() => expect(getQueueCount(cache)).toEqual(0))
|
.then(() => expect(getQueueCount(cache)).toEqual(0))
|
||||||
.then(done);
|
.then(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should start and connect cache adapter', async () => {
|
||||||
|
const server = await reconfigureServer({
|
||||||
|
cacheAdapter: {
|
||||||
|
module: `${__dirname.replace('/spec', '')}/lib/Adapters/Cache/RedisCacheAdapter`,
|
||||||
|
options: {
|
||||||
|
url: 'redis://127.0.0.1:6379/1',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const symbol = Object.getOwnPropertySymbols(server.config.cacheController);
|
||||||
|
const client = server.config.cacheController[symbol[0]].client;
|
||||||
|
expect(client.isOpen).toBeTrue();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -94,10 +94,10 @@ class ParseServer {
|
|||||||
const {
|
const {
|
||||||
databaseController,
|
databaseController,
|
||||||
hooksController,
|
hooksController,
|
||||||
|
cacheController,
|
||||||
cloud,
|
cloud,
|
||||||
security,
|
security,
|
||||||
schema,
|
schema,
|
||||||
cacheAdapter,
|
|
||||||
liveQueryController,
|
liveQueryController,
|
||||||
} = this.config;
|
} = this.config;
|
||||||
try {
|
try {
|
||||||
@@ -112,8 +112,11 @@ class ParseServer {
|
|||||||
if (schema) {
|
if (schema) {
|
||||||
startupPromises.push(new DefinedSchemas(schema, this.config).execute());
|
startupPromises.push(new DefinedSchemas(schema, this.config).execute());
|
||||||
}
|
}
|
||||||
if (cacheAdapter?.connect && typeof cacheAdapter.connect === 'function') {
|
if (
|
||||||
startupPromises.push(cacheAdapter.connect());
|
cacheController.adapter?.connect &&
|
||||||
|
typeof cacheController.adapter.connect === 'function'
|
||||||
|
) {
|
||||||
|
startupPromises.push(cacheController.adapter.connect());
|
||||||
}
|
}
|
||||||
startupPromises.push(liveQueryController.connect());
|
startupPromises.push(liveQueryController.connect());
|
||||||
await Promise.all(startupPromises);
|
await Promise.all(startupPromises);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function destroyAllDataPermanently(fast) {
|
|||||||
Object.keys(AppCache.cache).map(appId => {
|
Object.keys(AppCache.cache).map(appId => {
|
||||||
const app = AppCache.get(appId);
|
const app = AppCache.get(appId);
|
||||||
const deletePromises = [];
|
const deletePromises = [];
|
||||||
if (app.cacheAdapter) {
|
if (app.cacheAdapter && app.cacheAdapter.clear) {
|
||||||
deletePromises.push(app.cacheAdapter.clear());
|
deletePromises.push(app.cacheAdapter.clear());
|
||||||
}
|
}
|
||||||
if (app.databaseController) {
|
if (app.databaseController) {
|
||||||
|
|||||||
Reference in New Issue
Block a user