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

Initial draft for @lombok.experimental.Memoize #3396

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 5, 2023

  1. Initial draft for @lombok.experimental.Memoize

    This is an initial draft for how an @memoize annotation could look like.
    It currently lacks features such as:
    
     - Thread safety
     - Cache invalidation
     - Soft/Weak References for a lower memory profile
     - Avoiding using a Map entirely for parameterless methods
    
    Ideally at least some of these properties should be configurable using
    flags and/or annotation properties (some users might prefer a non
    thread safe cache for better performance).
    
    Example Usage:
    
    ```java
    class Test {
        int invocationCount = 0;
    
        public static void main(String[] args) {
            Test test = new Test();
            System.out.println(test.x(1, 2));
            System.out.println(test.x(1, 2));
            System.out.println(test.x(1, 3));
            System.out.println("Invocation Count: " + test.invocationCount);
        }
    
        @lombok.experimental.Memoize
        public int x(int y, int z) {
            invocationCount++;
            return y + z;
        }
    }
    ```
    nea89o committed Apr 5, 2023
    Configuration menu
    Copy the full SHA
    83c6368 View commit details
    Browse the repository at this point in the history