Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CacheAdapter does not connect when using a CacheAdapter with a JSON config #8633

Merged
merged 5 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions spec/RedisCacheAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,18 @@ describe_only(() => {
.then(() => expect(getQueueCount(cache)).toEqual(0))
.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();
});
});
9 changes: 6 additions & 3 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ class ParseServer {
const {
databaseController,
hooksController,
cacheController,
cloud,
security,
schema,
cacheAdapter,
liveQueryController,
} = this.config;
try {
Expand All @@ -112,8 +112,11 @@ class ParseServer {
if (schema) {
startupPromises.push(new DefinedSchemas(schema, this.config).execute());
}
if (cacheAdapter?.connect && typeof cacheAdapter.connect === 'function') {
startupPromises.push(cacheAdapter.connect());
if (
cacheController.adapter?.connect &&
typeof cacheController.adapter.connect === 'function'
) {
startupPromises.push(cacheController.adapter.connect());
}
startupPromises.push(liveQueryController.connect());
await Promise.all(startupPromises);
Expand Down
2 changes: 1 addition & 1 deletion src/TestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function destroyAllDataPermanently(fast) {
Object.keys(AppCache.cache).map(appId => {
const app = AppCache.get(appId);
const deletePromises = [];
if (app.cacheAdapter) {
if (app.cacheAdapter && app.cacheAdapter.clear) {
deletePromises.push(app.cacheAdapter.clear());
}
if (app.databaseController) {
Expand Down
Loading