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

feat(cache)!: use cachestore to cache request in server #111

Merged
merged 11 commits into from
Sep 2, 2020

Conversation

hongalex
Copy link
Collaborator

@hongalex hongalex commented Aug 29, 2020

What type of PR is this?
/kind feat

What this PR does / Why we need it:
Adds caching support to the Triton server implementation, storing Records in the cachestore assuming the size is less than 10 MiB.

BREAKING: Cache implementation now uses byte arrays are values rather than strings. This should have minimal effect since the cache store wasn't being used in the server logic before.

Which issue(s) this PR fixes:

Closes #110

Special notes for your reviewer:
This doesn't close issue #64 because we need to rework the caching hint implementation.

@hongalex hongalex requested a review from yuryu August 29, 2020 02:34
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

We should also include the Hint in the caching logic to provide clients with more control over caching specific records (or not):
DO_NOT_CACHE - during creation / update
IGNORE_CACHE - for get requests

Update: Captured in #64 (comment)

return fmt.Sprintf("%s/%s", storeKey, recordKey)
}

// EncodeRecord serializes a tritonpb Record with gob/base64.
Copy link
Member

Choose a reason for hiding this comment

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

I think Redis is binary-safe (https://redis.io/topics/data-types) so we don't need to encode it with base64. Is there a reason why we do the text encoding/decoding?

@hongalex hongalex changed the title feat: use cachestore to cache request in server feat(cache)!: use cachestore to cache request in server Sep 2, 2020
@hongalex
Copy link
Collaborator Author

hongalex commented Sep 2, 2020

@yuryu I removed the base64 encoding, but also made a breaking change to cache, so that Get and Set use []byte for values rather than string values.

While Redis supports any number of data types as keys and values, I think key: string, value: []byte makes the most sense. We could potentially support generic interfaces for the cache store, but not all cache stores (e.g. memcached) support that.

Copy link
Member

@yuryu yuryu left a comment

Choose a reason for hiding this comment

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

lgtm

@yuryu
Copy link
Member

yuryu commented Sep 2, 2020

Re: the interface, I think it makes sense for now to just store everything as binary. We could improve memory utilization and potentially implement atomic operations (add, inc, etc) in the cache too but doing so now seems like a premature optimization to me.

@hongalex hongalex merged commit b316902 into master Sep 2, 2020
@hongalex hongalex deleted the server-caching branch September 2, 2020 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cache support to the server code
3 participants