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: set fixed cache for active scenes and add all scenes getter #1829

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

leanmendoza
Copy link

@leanmendoza leanmendoza commented Nov 13, 2024

This change introduces a handler to retrieve all the cached scenes. Also, the scene entities are pre-cached at the start and unaffected by the LRU logic.

@leanmendoza leanmendoza changed the title wip add fetch entities ids feat: add fetch entities ids Nov 13, 2024
@leanmendoza leanmendoza changed the title feat: add fetch entities ids feat: set fixed cache for active scenes and add all scenes getter Nov 19, 2024
@leanmendoza leanmendoza marked this pull request as ready for review November 19, 2024 11:22
Signed-off-by: Lean Mendoza <[email protected]>
return cache.get(entityId) || fixedCache.get(entityId)
},
set(entityId: string, entity: Entity | NotActiveEntity) {
const isFixed = fixedCache.has(entityId) || (typeof entity !== 'string' && fixedTypes.includes(entity.type))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ain't the second part of the condition enough to use the fixedCache? (I mean if entity type is SCENE we should already store it regardless if it is already stored there, right?)


function getAllCachedScenes() {
return Array.from(fixedCache.values()).filter(
(entity): entity is Entity => typeof entity !== 'string' && entity.type === EntityType.SCENE
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not familiar with this check, but can we prevent typeof entity !== string on setting time instead of retrieve time?

Copy link
Author

Choose a reason for hiding this comment

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

The LRU cache was already with this workaround for unsetting pointers with no longer active entities. I haven't had the intention of modifying this current behavior

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

Successfully merging this pull request may close these issues.

2 participants