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: Implement Listener for Cache Renewals #104

Open
Johannes-Schneider opened this issue Feb 9, 2023 · 0 comments
Open

Feat: Implement Listener for Cache Renewals #104

Johannes-Schneider opened this issue Feb 9, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Johannes-Schneider
Copy link
Contributor

Johannes-Schneider commented Feb 9, 2023

Context

Some applications / libraries perform (heavy) calculations on the service bindings returned from the ServiceBindingAccessor.
For example, service bindings should be transformed into an application internal representation.
To safe computational overhead, applications may want to cache their internal objects instead of doing the transformation each and every time when they access ServiceBindingAccess#getBindings.

Unfortunately, by doing so, application might be out of sync with the actual service bindings.

Request

It would be great if applications would get notified whenever a new set of service bindings is created / returned by a ServiceBindingAccessor instance.

Suggestions

Workaround proposal:

@RequiredArgsConstructor
class ServiceBindingTransformer {
    @Nonnull
    private final ServiceBindingAccessor delegate;

    @Nullable
    private List<ServiceBinding> lastServiceBindings;
    @Nullable
    private List<MyTransformedServiceBinding> transformedBindings;

    @Nonnull
    public List<MyTransformedServiceBinding> getTransformedBindings()
    {
        final List<ServiceBinding> currentServiceBindings = delegate.getServiceBindings();
        if (currentServiceBindings != lastServiceBindings || transformedBindings == null)
        {
            // this will only be done in case the bindings were not served from a cache
            transformedBindings = transformBindings(currentServiceBindings);
            lastServiceBindings = currentServiceBindings;
        }

        return transformedBindings;
    }

    private List<MyTransformedServiceBinding> transformBindings(@Nonnull final List<ServiceBinding> bindings)
    {
        // TODO: implement me
    }
}

private static class MyTransformedServiceBinding {

}

Questions

  • How do we solve the multi-level caching? (e.g. K8s file system cache and simple cache)
@Johannes-Schneider Johannes-Schneider added the enhancement New feature or request label Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant