-
Notifications
You must be signed in to change notification settings - Fork 106
feat: implement per-user presentation compiler caching #1224
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
base: main
Are you sure you want to change the base?
Conversation
| setMetalsStatus: MetalsStatus ~=> Callback, | ||
| dependencies: Set[ScalaDependency]) | ||
| dependencies: Set[ScalaDependency], | ||
| user: Option[User]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just always generate random uuid for client, what is more. I think that you can generate it when someone enters the website and dont store it in local storage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
| * @param userUuid - unique identifier for the user | ||
| * @param newConfiguration - the new configuration being requested | ||
| */ | ||
| private def findAndRemoveOldPCForUser(userUuid: String, newConfiguration: ScastieMetalsOptions): IO[Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we don't need to do this ? Cache entries have 5 min expiration time. I'm also not sure how it is implemented underneath. Is key.cache blocking whole access to the cache ? Is it non-blocking ? If it is non blocking how it will behave when during the cleanup we send another new request from same user and different config. Concurrency is hard. If I were you I'd drop this method and just leave it up to the cache
8104f6e to
d96a8e7
Compare
metals-runner/src/main/scala/org/scastie/metals/ScastieMetals.scala
Outdated
Show resolved
Hide resolved
Add UUID-based user identification to limit each user (anonymous or authenticated) to one presentation compiler at a time. Anonymous users get a persistent UUID stored in localStorage, while authenticated users use their GitHub login as identifier.
739e3c0 to
b0d1e9b
Compare
Summary
Implements per-user presentation compiler (PC) caching. Each user (anonymous or authenticated) can now have at most one presentation compiler instance.
Key Changes
LocalStorage.getOrCreateClientUuid()to generate and persist UUIDs for anonymous users.Cache[IO, ScastieMetalsOptions, PC]toCache[IO, (String, ScastieMetalsOptions), PC]where String is the user UUID.