memoization.java

Java memoization library

https://github.com/metio/memoization.java

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.5%) to scientific vocabulary

Keywords

cache java memoization memoize
Last synced: 4 months ago · JSON representation ·

Repository

Java memoization library

Basic Info
  • Host: GitHub
  • Owner: metio
  • License: 0bsd
  • Language: Java
  • Default Branch: main
  • Homepage:
  • Size: 847 KB
Statistics
  • Stars: 18
  • Watchers: 1
  • Forks: 3
  • Open Issues: 1
  • Releases: 20
Topics
cache java memoization memoize
Created almost 10 years ago · Last pushed almost 2 years ago
Metadata Files
Readme Contributing License Code of conduct Citation Security Authors

README.md

memoization.java Chat

Java memoization library - trade space for time

Features

  • Memoize calls to JDK interfaces like Consumer, Function, Predicate, Supplier, and more
  • Memoize calls to jOOL interfaces like Consumer0..16 and Function0..16
  • Memoize calls to lambda interfaces like Fn0..8
  • Memoize calls to RxJava interfaces like Action, Cancellable, and more
  • Use custom caches like Caffeine, Guava, cache2k, or any ConcurrentMap.
  • Use custom cache keys for fine-tuning

Usage

Memoize any of the supported types by using the static factory methods supplied by:

  • Memoize if you want to memoize JDK interfaces.
  • MemoizeJool if you want to memoize jOOL interfaces.
  • MemoizeLambda if you want to memoize lambda interfaces.
  • MemoizeRx if you want to memoize RxJava interfaces.

Default cache with default cache keys

```java wtf.metio.memoization.jdk.Memoize; wtf.metio.memoization.jool.MemoizeJool; wtf.metio.memoization.lambda.MemoizeLambda; wtf.metio.memoization.rxjava.MemoizeRx;

Function function = ...; Function memoizedFunction = Memoize.function(function);

Supplier supplier = ...; Supplier memoizedSupplier = MemoizeRx.supplier(supplier);

Function3 function = ...; Function3 memoizedFunction = MemoizeJool.function3(function);

Fn4 function = ...; Fn4 memoizedFunction = MemoizeLambda.fn4(function); ```

Default cache with custom cache keys

```java wtf.metio.memoization.jdk.Memoize; wtf.metio.memoization.jool.MemoizeJool; wtf.metio.memoization.lambda.MemoizeLambda; wtf.metio.memoization.rxjava.MemoizeRx;

Function function = ...; Function keyFunction = ...; Function memoizedFunction = Memoize.function(function, keyFunction);

Supplier supplier = ...; Supplier keySupplier = ...; Supplier memoizedSupplier = MemoizeRx.supplier(supplier, keySupplier);

Function3 function = ...; Function3 keyFunction = ...; Function3 memoizedFunction = MemoizeJool.function3(function, keyFunction);

Fn4 function = ...; Fn4 keyFunction = ...; Fn4 memoizedFunction = MemoizeLambda.fn4(function, keyFunction); ```

Custom cache with default cache keys

```java wtf.metio.memoization.jdk.Memoize; wtf.metio.memoization.jool.MemoizeJool; wtf.metio.memoization.lambda.MemoizeLambda; wtf.metio.memoization.rxjava.MemoizeRx;

// memoize in cache2k cache Function function = ...; Cache cache = ...; // org.cache2k.Cache Function memoizedFunction = Memoize.function(function, cache.asMap());

// memoize in Caffeine cache Supplier supplier = ...; Cache cache = ...; // com.github.benmanes.caffeine.cache.Cache Supplier memoizedSupplier = MemoizeRx.supplier(supplier, cache.asMap());

// memoize in Guava cache Function3 function = ...; Cache cache = ...; // com.google.common.cache.Cache Function3 memoizedFunction = MemoizeJool.function3(function, cache.asMap());

// memoize in ConcurrentMap Fn4 function = ...; Map cache = ...; Fn4 memoizedFunction = MemoizeLambda.fn4(function, cache); ```

Custom cache with custom cache keys

```java wtf.metio.memoization.jdk.Memoize; wtf.metio.memoization.jool.MemoizeJool; wtf.metio.memoization.lambda.MemoizeLambda; wtf.metio.memoization.rxjava.MemoizeRx;

// memoize in cache2k cache Function function = ...; Function keyFunction = ...; Cache cache = ...; // org.cache2k.Cache Function memoizedFunction = Memoize.function(function, keyFunction, cache.asMap());

// memoize in Caffeine cache Supplier supplier = ...; Supplier keySupplier = ...; Cache cache = ...; // com.github.benmanes.caffeine.cache.Cache Supplier memoizedSupplier = MemoizeRx.supplier(supplier, keySupplier, cache.asMap());

// memoize in Guava cache Function3 function = ...; Function3 keyFunction = ...; Cache cache = ...; // com.google.common.cache.Cache Function3 memoizedFunction = MemoizeJool.function3(function, keyFunction, cache.asMap());

// memoize in ConcurrentMap Fn4 function = ...; Fn4 keyFunction = ...; Map cache = ...; Fn4 memoizedFunction = MemoizeLambda.fn4(function, keyFunction, cache); ```

Note that the static factory methods do accept any Map, however they copy the entries in the map to a new ConcurrentHashMap in case the provided Map is not a ConcurrentMap. This is done in order to ensure atomic computeIfAbsent behavior.

Integration

In order to use this project, declare the following dependencies in your project:

```xml <!-- support for JDK interfaces --> wtf.metio.memoization memoization-jdk ${version.memoization} <!-- support for JDK interfaces -->

<!-- support for jOOL interfaces -->
<dependency>
    <groupId>wtf.metio.memoization</groupId>
    <artifactId>memoization-jool</artifactId>
    <version>${version.memoization}</version>
</dependency>
<!-- support for jOOL interfaces -->

<!-- support for lambda interfaces -->
<dependency>
    <groupId>wtf.metio.memoization</groupId>
    <artifactId>memoization-lambda</artifactId>
    <version>${version.memoization}</version>
</dependency>
<!-- support for lambda interfaces -->

<!-- support for RxJava interfaces -->
<dependency>
    <groupId>wtf.metio.memoization</groupId>
    <artifactId>memoization-rxjava</artifactId>
    <version>${version.memoization}</version>
</dependency>
<!-- support for RxJava interfaces -->

```

Replace ${version.memoization} with the latest release.

Alternatives

License

``` Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ```

Owner

  • Name: metio.wtf
  • Login: metio
  • Kind: organization

Citation (CITATION.cff)

# SPDX-FileCopyrightText: The memoization.java Authors
# SPDX-License-Identifier: 0BSD

cff-version: 1.2.0
title: memoization.java
message: If you use this software, please cite it as below.
type: software
authors:
- family-names: Hoß
  given-names: Sebastian
  email: seb@hoß.de
url: https://github.com/metio/memoization.java
license: 0BSD
keywords:
  - cache
  - java
  - make
  - maven
  - memoization

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1

Issues and Pull Requests

Last synced: about 1 year ago

All Time
  • Total issues: 190
  • Total pull requests: 1
  • Average time to close issues: 3 months
  • Average time to close pull requests: 1 minute
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • sebhoss (99)
Pull Request Authors
  • sebhoss (2)
  • gitter-badger (1)
Top Labels
Issue Labels
Component: API (81) Cache: ConcurrentMap (37) Cache: Guava (35) Cache: Caffeine (14) Component: Build (11) Component: Documentation (3) Component: Implementation (2) Cache: JSR107 (1) Component: Test (1)
Pull Request Labels
enhancement (2)

Dependencies

memoization-core/pom.xml maven
  • de.xn--ho-hia.quality:suppress-warnings
  • junit:junit test
  • org.mockito:mockito-core test
pom.xml maven
  • de.xn--ho-hia.memoization:memoization-caffeine 2.0.0-SNAPSHOT
  • de.xn--ho-hia.memoization:memoization-core 2.0.0-SNAPSHOT
  • de.xn--ho-hia.memoization:memoization-guava 2.0.0-SNAPSHOT
  • de.xn--ho-hia.memoization:memoization-jcache 2.0.0-SNAPSHOT
.github/actions/managed-java/action.yml actions
  • actions/setup-java v3 composite
.github/actions/managed-maven/action.yml actions
  • actions/setup-java v3 composite
.github/workflows/codeql-analysis.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-java v3 composite
  • github/codeql-action/analyze v2 composite
  • github/codeql-action/autobuild v2 composite
  • github/codeql-action/init v2 composite
.github/workflows/release.yml actions
  • ./.github/actions/managed-maven * composite
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • dawidd6/action-send-mail v3.7.1 composite
  • s3krit/matrix-message-action v0.0.3 composite
  • softprops/action-gh-release v1 composite
  • timheuer/base64-to-file v1.2 composite
.github/workflows/reuse.yml actions
  • actions/checkout v3 composite
  • fsfe/reuse-action v1 composite
.github/workflows/update-parent.yml actions
  • ./.github/actions/managed-java * composite
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • peter-evans/create-pull-request v4 composite
  • peter-evans/enable-pull-request-automerge v2 composite
.github/workflows/verify.yml actions
  • ./.github/actions/managed-java * composite
  • actions/cache v3 composite
  • actions/checkout v3 composite
memoization-jdk/pom.xml maven
  • com.github.spotbugs:spotbugs-annotations
  • org.jspecify:jspecify
  • wtf.metio.memoization:memoization-core
  • com.github.ben-manes.caffeine:caffeine test
  • com.google.guava:guava test
  • net.jodah:concurrentunit test
  • net.openhft:chronicle-map test
  • org.cache2k:cache2k-api test
  • org.cache2k:cache2k-core test
  • org.eclipse.collections:eclipse-collections test
  • org.eclipse.collections:eclipse-collections-api test
  • org.mockito:mockito-core test
  • wtf.metio.memoization:memoization-tck test
memoization-jool/pom.xml maven
  • com.github.spotbugs:spotbugs-annotations
  • org.jooq:jool
  • org.jspecify:jspecify
  • wtf.metio.memoization:memoization-core
  • com.github.ben-manes.caffeine:caffeine test
  • com.google.guava:guava test
  • net.jodah:concurrentunit test
  • net.openhft:chronicle-map test
  • org.cache2k:cache2k-api test
  • org.cache2k:cache2k-core test
  • org.eclipse.collections:eclipse-collections test
  • org.eclipse.collections:eclipse-collections-api test
  • org.mockito:mockito-core test
  • wtf.metio.memoization:memoization-tck test
memoization-lambda/pom.xml maven
  • com.github.spotbugs:spotbugs-annotations
  • com.jnape.palatable:lambda
  • org.jspecify:jspecify
  • wtf.metio.memoization:memoization-core
  • com.github.ben-manes.caffeine:caffeine test
  • com.google.guava:guava test
  • net.jodah:concurrentunit test
  • net.openhft:chronicle-map test
  • org.cache2k:cache2k-api test
  • org.cache2k:cache2k-core test
  • org.eclipse.collections:eclipse-collections test
  • org.eclipse.collections:eclipse-collections-api test
  • org.mockito:mockito-core test
  • wtf.metio.memoization:memoization-tck test
memoization-rxjava/pom.xml maven
  • com.github.spotbugs:spotbugs-annotations
  • io.reactivex.rxjava3:rxjava
  • org.jspecify:jspecify
  • wtf.metio.memoization:memoization-core
  • com.github.ben-manes.caffeine:caffeine test
  • com.google.guava:guava test
  • net.jodah:concurrentunit test
  • net.openhft:chronicle-map test
  • org.cache2k:cache2k-api test
  • org.cache2k:cache2k-core test
  • org.eclipse.collections:eclipse-collections test
  • org.eclipse.collections:eclipse-collections-api test
  • org.mockito:mockito-core test
  • wtf.metio.memoization:memoization-tck test
memoization-tck/pom.xml maven
  • org.jspecify:jspecify
  • org.junit.jupiter:junit-jupiter-api
  • wtf.metio.memoization:memoization-core