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 EntityClass#testCache(ID) overload #1276

Open
vlsi opened this issue Jun 18, 2021 · 1 comment
Open

Add EntityClass#testCache(ID) overload #1276

vlsi opened this issue Jun 18, 2021 · 1 comment

Comments

@vlsi
Copy link

vlsi commented Jun 18, 2021

Currently, only testCache(EntityID<ID>) is present, so please add testCache(ID):

fun testCache(id: EntityID<ID>): T? = warmCache().find(this, id)
fun testCache(cacheCheckCondition: T.() -> Boolean): Sequence<T> = warmCache().findAll(this).asSequence().filter { it.cacheCheckCondition() }

For instance, get(...) has two variations:

operator fun get(id: EntityID<ID>): T = findById(id) ?: throw EntityNotFoundException(id, this)
operator fun get(id: ID): T = get(DaoEntityID(id, table))

@vlsi
Copy link
Author

vlsi commented Jun 18, 2021

Workaround is

fun<ID: Comparable<ID>, T : Entity<ID>> EntityClass<ID, T>.testCache(id: ID) =
    testCache(EntityID(id, table))

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

No branches or pull requests

1 participant