-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Feature: Inflight Request Cache for Document Types and Data Types #19956
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a12db87
extend controller base
madsrasmussen 5d6415f
extend controller base
madsrasmussen 05a4235
add package for management api
madsrasmussen 6212027
add signalr as external package
madsrasmussen 2b1be18
connect to server event hub
madsrasmussen 2490bf8
do no act on undefined
madsrasmussen 8c592e3
add event subject
madsrasmussen c139362
correct alias
madsrasmussen 62799bd
export token
madsrasmussen 5a3f8f9
add helper methods
madsrasmussen 2deb7cc
cache server responses
madsrasmussen ad257cf
fix import
madsrasmussen 03c1fc8
use helpers
madsrasmussen 1f1baa6
add detail request manager
madsrasmussen a2c3283
implement for document type
madsrasmussen 9aa73a7
implement for data type
madsrasmussen 9d33c00
add method for update
madsrasmussen ba732e3
add support for create method
madsrasmussen 9e1deb6
align code
madsrasmussen cefc5e0
Update detail-request.manager.ts
madsrasmussen b38cdf2
move explicit naming
madsrasmussen 9905302
move into folder
madsrasmussen eef5acb
collect server code in folder
madsrasmussen 0045a74
add implementation for data type request manager
madsrasmussen 9058d26
implement for document type
madsrasmussen c9f701f
only cache when we have connection to the server events
madsrasmussen b34df6a
poc inflight request cache
madsrasmussen ed1a259
clean up
madsrasmussen da203e6
update
madsrasmussen e5911c0
Merge branch 'v16/feature/entity-detail-runtime-cache' into v16/bugfi…
madsrasmussen 2a4190a
Merge branch 'main' into v16/bugfix/inflight-request-cache
madsrasmussen a5bc05b
add management api inflight request cache
madsrasmussen 70e2c83
Update document-type-detail.server.request-manager.ts
madsrasmussen ac305bb
Update src/Umbraco.Web.UI.Client/src/packages/management-api/detail/d…
madsrasmussen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Umbraco.Web.UI.Client/src/packages/management-api/detail/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| export * from './detail-data.request-manager.js'; | ||
| export * from './cache.js'; | ||
| export * from './cache-invalidation.manager.js'; | ||
| export * from './cache.js'; | ||
| export * from './detail-data.request-manager.js'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export * from './detail/index.js'; | ||
| export * from './item/index.js'; | ||
| export * from './server-event/constants.js'; | ||
| export * from './inflight-request/cache.js'; | ||
| export type * from './types.js'; |
60 changes: 60 additions & 0 deletions
60
src/Umbraco.Web.UI.Client/src/packages/management-api/inflight-request/cache.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { UmbApiResponse } from '@umbraco-cms/backoffice/resources'; | ||
|
|
||
| // Keep internal | ||
| type RequestResolvedType<ResponseModelType> = UmbApiResponse<{ data?: ResponseModelType }>; | ||
|
|
||
| /** | ||
| * A cache for inflight requests to the Management Api. Use this class to cache requests and avoid duplicate calls. | ||
| * @class UmbManagementApiInflightRequestCache | ||
| * @template ResponseModelType | ||
| */ | ||
| export class UmbManagementApiInflightRequestCache<ResponseModelType> { | ||
| #entries = new Map<string, Promise<RequestResolvedType<ResponseModelType>>>(); | ||
|
|
||
| /** | ||
| * Checks if an entry exists in the cache | ||
| * @param {string} key - The ID of the entry to check | ||
| * @returns {boolean} - True if the entry exists, false otherwise | ||
| * @memberof UmbManagementApiInflightRequestCache | ||
| */ | ||
| has(key: string): boolean { | ||
| return this.#entries.has(key); | ||
| } | ||
|
|
||
| /** | ||
| * Adds an entry to the cache | ||
| * @param {string} key - A unique key representing the promise | ||
| * @param {Promise<UmbApiResponse<RequestResolvedType<ResponseModelType>>>} promise - The promise to cache | ||
| * @memberof UmbManagementApiInflightRequestCache | ||
| */ | ||
| set(key: string, promise: Promise<RequestResolvedType<ResponseModelType>>): void { | ||
| this.#entries.set(key, promise); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves an entry from the cache | ||
| * @param {string} key - The ID of the entry to retrieve | ||
| * @returns {Promise<RequestResolvedType<ResponseModelType>> | undefined} - The cached promise or undefined if not found | ||
| * @memberof UmbManagementApiInflightRequestCache | ||
| */ | ||
| get(key: string): Promise<RequestResolvedType<ResponseModelType>> | undefined { | ||
| return this.#entries.get(key); | ||
| } | ||
|
|
||
| /** | ||
| * Deletes an entry from the cache | ||
| * @param {string} key - The ID of the entry to delete | ||
| * @memberof UmbManagementApiInflightRequestCache | ||
| */ | ||
| delete(key: string): void { | ||
| this.#entries.delete(key); | ||
| } | ||
|
|
||
| /** | ||
| * Clears all entries from the cache | ||
| * @memberof UmbManagementApiInflightRequestCache | ||
| */ | ||
| clear(): void { | ||
| this.#entries.clear(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.