Get Free Trial

flexmonster-mongo-connector getDataFromCache issue

Rainer Wittmann asked on November 12, 2021

We have the need to support multiple databases and have expanded the pivot-mongo example as a POC.

Overall the result looks good, however, there’s an issue with the getDataFromCache method. As you can see it only gets the query passed in. However caching, must be accomplished based on a hash value of db/index and query values otherwise caching will return the wrong data.

    _getData(apiRequest) {
        return __awaiter(this, void 0, void 0, function* () {
            let query = JSON.stringify(apiRequest.requestArgument.clientQuery);
            let data
            // let data = this.getDataFromCache(query);
            LoggingManager_1.LoggingManager.log(`Client query: ${JSON.stringify(apiRequest.requestArgument.clientQuery)}`);
            if (data === undefined) {
                data = yield apiRequest.getData(this._queryBuilder, this._queryExecutor);
                this.setDataToCache(query, data);
                if (ConfigManager_1.ConfigManager.getInstance().currentConfig.cacheEnabled) {
                    LoggingManager_1.LoggingManager.log(`Putting ${apiRequest.loggingTemplate} data to cache`);
            else {
                LoggingManager_1.LoggingManager.log(`Getting ${apiRequest.loggingTemplate} data from cache`);
            return data;

2 answers

Nadia Khodakivska Nadia Khodakivska Flexmonster 7 days ago

Hello, Rainer,
Thank you for contacting us.
Your suggestion about the getDataFromCache method sounds reasonable. We have added an appropriate task to our backlog. I’m afraid that there is no clear ETA for this. Our team will notify you in case something is changed on this point. 
However, if it is important for your case, feel free to check a project with the MongoDB Connector on our GitHub and change the source code:
Please let us know if any questions arise.
Kind regards,

Rainer Wittmann 3 days ago

Ok, that will work. 

Please login or Register to Submit Answer