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

Passing in a existing memcached client ignores the secret option #39

Closed
danielb7390 opened this issue Mar 24, 2022 · 5 comments
Closed

Comments

@danielb7390
Copy link

I have a project that already has a memcached instance created, yet when adding connect-memcached, it will create a new instance of the client but i wanted to use the existing instance

Took a look at the code and i see i can pass in a client at MemcachedStore(), but for some reason in case a client is passed the secret option is ignored:

function MemcachedStore(options) {
options = options || {};
Store.call(this, options);
this.prefix = options.prefix || "";
this.ttl = options.ttl;
if (!options.client) {
if (!options.hosts) {
options.hosts = "127.0.0.1:11211";
}
if (options.secret) {
(this.crypto = require("crypto")), (this.secret = options.secret);
}
if (options.algorithm) {
this.algorithm = options.algorithm;
}
options.client = new Memcached(options.hosts, options);
}
this.client = options.client;
}

Shouldn't the if (options.secret) block be outside the if (!options.client)?

@balor
Copy link
Owner

balor commented Mar 24, 2022

@danielb7390 Valid observation, the same applies to algorithm option. Luckily I'm planning to do some long due chores on this repository this week so I'll be able to include fix for mentioned quirk.

@balor
Copy link
Owner

balor commented Mar 31, 2022

FYI I'm planning to add your case as a test, for this purpose I've migrated test "suite" from manual scripts to Jest. Next steps in progress.

@danielb7390
Copy link
Author

Thanks for the update!

@balor
Copy link
Owner

balor commented Apr 12, 2022

small update: working on merging this pr, which will also fix this issue along the way

@balor balor mentioned this issue Apr 17, 2022
@balor
Copy link
Owner

balor commented May 20, 2022

Version v2.0.0 should address this issue. In case you're using data encryption, remember to flush the session data before upgrading.

@balor balor closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants