Skip to content

Commit 720d24e

Browse files
authored
fix: CacheAdapter does not connect when using a CacheAdapter with a JSON config (#8633)
1 parent 2065897 commit 720d24e

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

spec/RedisCacheAdapter.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,18 @@ describe_only(() => {
167167
.then(() => expect(getQueueCount(cache)).toEqual(0))
168168
.then(done);
169169
});
170+
171+
it('should start and connect cache adapter', async () => {
172+
const server = await reconfigureServer({
173+
cacheAdapter: {
174+
module: `${__dirname.replace('/spec', '')}/lib/Adapters/Cache/RedisCacheAdapter`,
175+
options: {
176+
url: 'redis://127.0.0.1:6379/1',
177+
},
178+
},
179+
});
180+
const symbol = Object.getOwnPropertySymbols(server.config.cacheController);
181+
const client = server.config.cacheController[symbol[0]].client;
182+
expect(client.isOpen).toBeTrue();
183+
});
170184
});

src/ParseServer.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ class ParseServer {
9494
const {
9595
databaseController,
9696
hooksController,
97+
cacheController,
9798
cloud,
9899
security,
99100
schema,
100-
cacheAdapter,
101101
liveQueryController,
102102
} = this.config;
103103
try {
@@ -112,8 +112,11 @@ class ParseServer {
112112
if (schema) {
113113
startupPromises.push(new DefinedSchemas(schema, this.config).execute());
114114
}
115-
if (cacheAdapter?.connect && typeof cacheAdapter.connect === 'function') {
116-
startupPromises.push(cacheAdapter.connect());
115+
if (
116+
cacheController.adapter?.connect &&
117+
typeof cacheController.adapter.connect === 'function'
118+
) {
119+
startupPromises.push(cacheController.adapter.connect());
117120
}
118121
startupPromises.push(liveQueryController.connect());
119122
await Promise.all(startupPromises);

src/TestUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function destroyAllDataPermanently(fast) {
1313
Object.keys(AppCache.cache).map(appId => {
1414
const app = AppCache.get(appId);
1515
const deletePromises = [];
16-
if (app.cacheAdapter) {
16+
if (app.cacheAdapter && app.cacheAdapter.clear) {
1717
deletePromises.push(app.cacheAdapter.clear());
1818
}
1919
if (app.databaseController) {

0 commit comments

Comments
 (0)