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

Add support for Compare And Swap (CAS) to get, getMulti, and set #9

Merged
merged 20 commits into from
Apr 13, 2021

Conversation

justjake
Copy link

@justjake justjake commented Apr 12, 2021

  • Some monkeying around with directory structure to make build output directory more coherent
  • get and getMutli return CAS
  • set, delete, etc take CAS option

@justjake justjake requested a review from blackmad April 12, 2021 20:18
});
}
const logger = this.options.logger;

// TODO: support flags, support version (CAS)
this.incrSeq();
const expiration = makeExpiration((options || {}).expires || this.options.expires);
const expiration = makeExpiration(
(options || {}).expires || this.options.expires

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is on modern TS so we can do options?.expires now, forgot I think when I wrote this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO. I want to get to this in the next PR where I remove callbacks!

bench/memjs.js Show resolved Hide resolved
Comment on lines +63 to +64
* If Value and Extras are of type Buffer, then return type WhenBuffer. Otherwise,
* return type NotBuffer.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention that this is just for hacky tests?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not though?

Comment on lines 87 to 101
export interface GetResult<Value = MaybeBuffer, Extras = MaybeBuffer> {
value: Value;
extras: Extras;
cas: CASToken | undefined;
}

export type GetMultiResult<
Keys extends string = string,
Value = MaybeBuffer,
Extras = MaybeBuffer
> = {
[K in Keys]: GetResult<Value, Extras>;
};

class Client<Value = MaybeBuffer, Extras = MaybeBuffer> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is all this really for tests? I should suck it up and make them just be all buffers

src/memjs/memjs.ts Outdated Show resolved Hide resolved
@justjake justjake changed the title [WIP] Add support for Compare And Swap (CAS) Add support for Compare And Swap (CAS) to get, getMulti, and set Apr 13, 2021
@justjake justjake merged commit efce2eb into master Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants