Ehcache 3.x line

Related tags

Caching ehcache3
Overview

The Ehcache 3.x line is currently the development line.

Status of the build:

Build Status

For more information, you might want to go check the wiki.

Getting started with the new API

For samples, documentation, and usage information, please see http://ehcache.org.

Current release

We released 3.9.0 on August 25th 2020.

The release notes contain the links to the artifacts and the documentation to help you get started.

You should consider upgrading to 3.9.x as it does all previous 3.x do and more with a fully compatible API.

Current development & next release

We released the missing features of the clustering tier of Ehcache 3 in 3.7.0.

Starting with version 3.5, Ehcache only supports Java 8 and later.

Version 3.5 is now in maintenance mode. We are no longer planning to perform release of earlier versions.

See the milestones on GitHub for more details on the current status.

Contribute

With great pleasure! Have a look at our Contributing policy.

Reporting issues

Oh no! We have no bugs! (but if we really do, see details for reporting here).

Comments
  • Issue 39

    Issue 39

    There may still be some rough edges here. In particular, it feels like CacheWriter.write(K, V) needs to be split into insert and update, and return a value. Also, an attempt was made to whip compute/write functions for bulk CRUD methods into shape, to blaze the trail for fixing #110... not super convinced they are correct now though.

    opened by vfunshteyn 25
  • Any plans to offer a Jakarta version?

    Any plans to offer a Jakarta version?

    In playing around with migrating Hibernate to Jakarta Persistence APIs I ran into trouble with our hibernate-jcache module. The only hang up I saw was that ehcache3 uses JAXB which would need to be updated to use Jakarta's JAXB apis/impls.

    Having done this for Hibernate I can offer some help/guidance. Let me know

    opened by sebersole 22
  • issue #72, Exipration stuff

    issue #72, Exipration stuff

    Plenty of questionable things in here:

    • The interface of org.ehcache.expiry.Expiry
    • The way Expiry gets into a Cache and then onto the Store, as explicit methods on the config objects
    • The way the TimeSource gets into OnHeapStore (no idea if I used the service config concept correctly)
      • see org.ehcache.internal.store.OnHeapStore.Provider
    opened by timeck 20
  • Per key metadata sharing across clients in clustered ehcache

    Per key metadata sharing across clients in clustered ehcache

    For a multi-tiered clustered cache manager, that has a cache that has either TTI and TTL configured, there are two challenges with respect to per-key metadata that needs to be addressed..

    When a client does a get on a key locally from its caching tier, other clients doing a get on the same key later must somehow see the correct access time for this key locally in order to accurately compute 'time to idle' and decide whether an entry needs to be expired or not.

    For both TTL and TTI computations with clients having different clocks, the computations must ensure that the clocks are synchronized across multiple VMs/systems either by using a single time reference (say of the server) for absolute time with clients computing time relative to this absolute time or by ensuring that the clocks are synchronized using internal or external clock synchronization mechanisms.

    clustering spi 
    opened by rkavanap 19
  • #170, added test cases for StoreEventListener on expiration and eviction

    #170, added test cases for StoreEventListener on expiration and eviction

    Hi Please review this pull request, few things to notice:

    1. I moved TimeSource from impl to core module as i needed access to TimeSource for writing expiration tests.
    2. There is a bug in testPutIfAbsentOnEviction test, as putIfAbsent call puts key/value in store even thou store capacity is reached.

    Thanks

    Gaurav

    opened by gmangalick1 18
  • Issue 101

    Issue 101

    Shouldn't be too off... For @timeck the ParsesConfigExtensionTest class contains my take on how to make this all work within our javax.cache.CacheManager implementation...

    opened by alexsnaps 17
  • Support system properties replacement in Ehcache xml

    Support system properties replacement in Ehcache xml

    As requested on the mailing list this is a feature that makes sense.

    @alexsnaps already made an initial PR to support this -see #1426 I believe it is a good start but it misses enabling substitution for attributes / element text that are defined as numbers. For example in <heap>10</heap>.

    And also there is a remark about NCname problems.

    So this issue exists to track exactly what will be possible / supported and what will not regarding property substitution.

    enhancement question api 
    opened by ljacomet 16
  • Issue 118

    Issue 118

    Goal: exposing statistics result

    Method: the gathering process is adapted from Ehcache 2 code base. It's simplified to expose just what JSR107 needed.

    Concerns:

    1. Clearing stats: needs to find a way to clear all the stats
    2. Average time spent in gets/puts: was told by Chris it's doable with mean latency from stats module but I have found no example of how to wire it up
    3. Old CacheManager will provide a shared instance of ScheduledExecutorService to every cache for stats gathering. This model isn't the same in Ehcache3 since we have EhcacheManager and StandaloneCacheBuilder both creating an Ehcache instance. I've ended up creating the executor in both of these places for now. Also, to avoid an NPE from initiating a statistics gateway in other tests in which Ehcache instance is created from constructor, a default executor is being used (see Ehcache.java line 103). This is just a hack to get the tests running. It's definitely needed revised.
    4. Testing: testing statistics required a real Ehcache usage with OnheapStore backing. It doesn't seem it could be done inside "core" module since it's missing OnheapStore from the "impl" module. I had to place my statistics test in "impl" as a result. The test is still in progress.
    opened by hhuynh 16
  • ClusteredStore's lack of support for iterator breaks JSR-107 removeAll()

    ClusteredStore's lack of support for iterator breaks JSR-107 removeAll()

    Since the 107 Cache.removeAll() method contract requires us to call both listeners and cache writers with every key deleted we rely on iterating the authoritative tier and removing each key individually. This isn't implemented in the clustered tier (arguably for good reasons), but this leaves a hole in our 107 implementation. This hole is exposed by Spring since an "evictAll" mapped method in a spring bean ends up calling this method. Independently we could consider looking in to having Spring call clear() instead of removeAll() but I suspect there are esoteric Spring configurations that might need the notifications that removeAll() gives. To fix this I think a two pronged approach would be a good plan:

    1. I think for non-loader-writer cases where are no listeners (probably the common case) we can dynamically choose to call clear directly since no will notice that trees are making noises as they fall.
    2. We'll need to implement some way of iterating the keys in the clustered store for cases where a writer or listener are present.

    We can probably treat the more complex/fuller solution with a lower priorirty since I think step 1 will solve the issue for the bulk of our users.

    bug duplicate 
    opened by chrisdennis 15
  • Getting Duplicate identity constraint name in Ehcache3.8.1 with XML Configuration

    Getting Duplicate identity constraint name in Ehcache3.8.1 with XML Configuration

    I'm getting below exception with ehcache 3.8.1 with XML Configuration file (the application is an EAR deployed to weblogic server). Did anyone faced this issues? When debugged the code in ehcache, I could find that getting three XML schema in below code snipped of ConfigurationParser.java and failing with duplicate. Is I'm doing any wrong?

     public static Schema discoverSchema(Source ... fixedSources) throws SAXException, IOException {
        ArrayList<Source> schemaSources = new ArrayList<>(asList(fixedSources));
        for (CacheManagerServiceConfigurationParser<?> p : servicesOfType(CacheManagerServiceConfigurationParser.class)) {
          schemaSources.add(p.getXmlSchema());
        }
        for (CacheServiceConfigurationParser<?> p : servicesOfType(CacheServiceConfigurationParser.class)) {
          schemaSources.add(p.getXmlSchema());
        }
        for (CacheResourceConfigurationParser p : servicesOfType(CacheResourceConfigurationParser.class)) {
          schemaSources.add(p.getXmlSchema());
        }
        return newSchema(schemaSources.toArray(new Source[0]));
      }
    

    Getting the following exception

    Error on line 28
      Duplicate identity constraint name {default-template-ref} - previously defined on line 28 of
    Error on line 37
      Duplicate identity constraint name {template-ref} - previously defined on line 37 of
    org.ehcache.xml.exceptions.XmlConfigurationException: Error parsing XML configuration at file:/D:/*********/UIM/config/ehcache3.xml
            at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:124) ~[ehcache-3.8.1.jar:3.8.1 a19322e8d4b3f7157e878112c2afc0b6e3090fdd]
            at org.ehcache.xml.XmlConfiguration.<init>(XmlConfiguration.java:90) ~[ehcache-3.8.1.jar:3.8.1 a19322e8d4b3f7157e878112c2afc0b6e3090fdd]
    

    The code is as follows:

    URL url = getClass().getResource("/"+configFileName);
    Configuration xmlConfig = new XmlConfiguration(url);
    admin = CacheManagerBuilder.newCacheManager(xmlConfig);
    admin.init();
    

    The xml configuration is as follows:

    <config
        xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
    	xmlns:tc='http://www.ehcache.org/v3/clustered'
        xmlns="http://www.ehcache.org/v3"
    	xsi:schemaLocation="
                http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core.xsd
    			http://www.ehcache.org/v3/clustered http://www.ehcache.org/schema/ehcache-clustered-ext.xsd">
    			
      <service>
        <tc:cluster>
          <tc:connection url="terracotta://localhost:9410/clustered"/>
          <tc:server-side-config auto-create="true">
            <tc:default-resource from="default-resource"/>
          </tc:server-side-config>
        </tc:cluster>  
      </service>  
       
      <cache-template name="myDefaults"> 
        <key-type>java.lang.String</key-type>
        <value-type>java.io.Serializable</value-type>
        <heap unit="entries">1000</heap>
      </cache-template>
      
      <cache alias="frameworkCache">
        <key-type>java.lang.String</key-type>
        <value-type>java.io.Serializable</value-type>
        <resources>
          <tc:clustered-dedicated unit="MB">5</tc:clustered-dedicated>
    	</resources>
      </cache>
      
      <cache alias="isolatedCache">
       <key-type>java.lang.String</key-type>
       <value-type>java.io.Serializable</value-type>
       <resources>
       	  <heap unit="MB">10</heap>
    	</resources>
      </cache>
      
      <cache alias="default" uses-template="myDefaults" >
        <key-type>java.lang.String</key-type>
        <value-type>java.io.Serializable</value-type>
        <resources>
          <tc:clustered-dedicated unit="MB">5</tc:clustered-dedicated>
    	</resources>
      </cache>
    
    </config>
    
    opened by santhoshpt 14
  • Ehcache fails to reconnect to server after a while

    Ehcache fails to reconnect to server after a while

    I'm cutting and re-establishing the network connection between a client and a server. It works for a little while but fails at some point. The client never reconnects.

    Here is the test case. It is using toxiproxy server launched locally with default parameters.

    In build.gradle:

    testCompile 'eu.rekawek.toxiproxy:toxiproxy-java:2.1.2'
    
    import eu.rekawek.toxiproxy.Proxy;
    import eu.rekawek.toxiproxy.ToxiproxyClient;
    import org.ehcache.Cache;
    import org.ehcache.PersistentCacheManager;
    import org.ehcache.clustered.client.config.builders.ClusteredResourcePoolBuilder;
    import org.ehcache.clustered.client.config.builders.ClusteredStoreConfigurationBuilder;
    import org.ehcache.clustered.client.config.builders.ClusteringServiceConfigurationBuilder;
    import org.ehcache.clustered.client.config.builders.TimeoutsBuilder;
    import org.ehcache.clustered.common.Consistency;
    import org.ehcache.config.builders.CacheConfigurationBuilder;
    import org.ehcache.config.builders.CacheManagerBuilder;
    import org.ehcache.config.builders.ResourcePoolsBuilder;
    import org.ehcache.config.units.MemoryUnit;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.ClassRule;
    import org.junit.Rule;
    import org.junit.Test;
    import org.junit.rules.TestName;
    import org.terracotta.testing.rules.Cluster;
    
    import java.io.File;
    import java.io.IOException;
    import java.net.URI;
    import java.time.Duration;
    import java.util.concurrent.Phaser;
    import java.util.concurrent.atomic.AtomicReference;
    
    import static eu.rekawek.toxiproxy.model.ToxicDirection.DOWNSTREAM;
    import static org.assertj.core.api.Assertions.assertThat;
    import static org.terracotta.testing.rules.BasicExternalClusterBuilder.newCluster;
    
    public class NetworkFailureTest extends ClusteredTests {
    
      private static final String RESOURCE_CONFIG =
        "<config xmlns:ohr='http://www.terracotta.org/config/offheap-resource'>"
        + "<ohr:offheap-resources>"
        + "<ohr:resource name=\"primary-server-resource\" unit=\"MB\">512</ohr:resource>"
        + "</ohr:offheap-resources>"
        + "</config>"
        + "<service xmlns:lease='http://www.terracotta.org/service/lease'>"
        + "<lease:connection-leasing>"
        + "<lease:lease-length unit='seconds'>5</lease:lease-length>"
        + "</lease:connection-leasing>"
        + "</service>\n";
    
      private PersistentCacheManager cacheManager;
    
      private ToxiproxyClient client;
      private Proxy activeProxy;
    
      @ClassRule
      public static Cluster CLUSTER = newCluster(1)
        .in(new File("build/cluster"))
        .withServiceFragment(RESOURCE_CONFIG)
        .build();
    
       @Rule
       public TestName name = new TestName();
    
      @Before
      public void startServers() throws Exception {
        CLUSTER.getClusterControl().startAllServers();
        CLUSTER.getClusterControl().waitForActive();
    
        URI clusterUri = CLUSTER.getConnectionURI();
    
        client = new ToxiproxyClient();
        try {
          activeProxy = client.getProxy("NetworkFailureTest.proxy");
          activeProxy.delete();
        } catch (IOException e) {
          // It means the proxy isn't there. Just ignore
        }
        activeProxy = client.createProxy("NetworkFailureTest.proxy", "0.0.0.0:21212", "localhost" + ":" + clusterUri.getPort());
    
        URI proxyUri = URI.create("terracotta://localhost:21212");
    
        CacheManagerBuilder<PersistentCacheManager> builder = CacheManagerBuilder.newCacheManagerBuilder()
          .with(ClusteringServiceConfigurationBuilder.cluster(proxyUri)
            .timeouts(TimeoutsBuilder.timeouts().write(Duration.ofSeconds(20)))
            .autoCreate())
          .withCache("cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Integer.class, String.class,
            ResourcePoolsBuilder.newResourcePoolsBuilder()
              .with(ClusteredResourcePoolBuilder.clusteredDedicated("primary-server-resource", 32, MemoryUnit.MB)))
            .add(ClusteredStoreConfigurationBuilder.withConsistency(Consistency.STRONG)));
    
        cacheManager =  builder.build(true);
      }
    
      @After
      public void tearDown() throws Exception {
        System.out.println("*************************************************** TearDown ***************************************************");
        client.reset();
    
        if(cacheManager != null) {
          cacheManager.close();
          cacheManager.destroy();
        }
        activeProxy.delete();
    
        CLUSTER.getClusterControl().terminateAllServers();
      }
    
      @Test
      public void proxy() throws Exception {
    
        Cache<Integer, String> cache = cacheManager.getCache("cache", Integer.class, String.class);
    
        for (int i = 0; i < 100; i++) {
          System.out.println("***************************************** Loop: " + i);
          upAndDown(cache);
        }
      }
    
      private void upAndDown(Cache<Integer, String> cache) throws InterruptedException {
        Phaser phaser = new Phaser(2);
    
        AtomicReference<Throwable> exception = new AtomicReference<>();
    
        Thread thread = new Thread(() -> {
          try {
            // Everything is alright phase
            phaser.arriveAndAwaitAdvance();
            Thread.sleep(5_000);
    
            // Loosing connection phase
            phaser.arriveAndAwaitAdvance();
            activeProxy.toxics().timeout("failing", DOWNSTREAM, 5_000);
            Thread.sleep(10_000);
    
            // Getting back connection phase
            phaser.arriveAndAwaitAdvance();
            activeProxy.toxics().get("failing").remove();
          } catch(Throwable e) {
            exception.set(e);
          } finally {
            phaser.arriveAndDeregister();
          }
        });
    
        thread.start();
    
        cache.put(1, "a");
    
        // Everything is alright phase
        System.out.println("************************** Alright");
        phaser.arriveAndDeregister();
        while(phaser.getPhase() == 0) {
          assertThat(cache.get(1)).isEqualTo("a");
          Thread.sleep(1_000);
        }
    
        // Loosing connection phase
        System.out.println("************************** Loosing");
        while(cache.get(1) != null) {
          Thread.sleep(1_000);
        }
    
        // Getting back connection phase
        System.out.println("************************** Back to our feet");
        while(cache.get(1) == null) {
          System.out.println("Trying to get connection back");
          cache.put(1, "a");
          Thread.sleep(1_000);
        }
    
        while(!phaser.isTerminated());
    
        assertThat(exception.get()).isNull();
    
        System.out.println("************************** All done");
      }
    }
    

    The full code is here: https://github.com/henri-tremblay/ehcache3/tree/networkingtest

    opened by henri-tremblay 14
  • Avoid IntelliJ's crude interpretation of XSD documentation sections that begin with

    Avoid IntelliJ's crude interpretation of XSD documentation sections that begin with "deprecated"

    IntelliJ has a somewhat crude heuristic that marks any xml element whose XSD documentation entry starts with "deprecated" as deprecated. This causes problems when we have conditional deprecation statements like:

    DEPRECATED: The use of memory units (such as 'B', 'kB' or 'MB') for heap resources is deprecated and will be removed in a future version.
    

    https://youtrack.jetbrains.com/issue/IDEA-199839

    Hat tip to @mrpiggi

    bug documentation 
    opened by chrisdennis 0
  • TieredStore doesn't populate the caching tier on getAll(...)

    TieredStore doesn't populate the caching tier on getAll(...)

    I have the following ehcache configuration. But it seems only the offheap component reports metrics(hits, size etc) but onheap is never allocated in this config.

    CacheManager cacheManager = CacheManagerBuilder.newCacheManagerBuilder()
                  .using(statisticsService)
                  .withCache("cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class, ResourcePoolsBuilder.newResourcePoolsBuilder()
                                              .heap(1, MemoryUnit.GB).offheap(3, MemoryUnit.GB).build())
                                              .withExpiry(ExpiryPolicyBuilder.timeToLiveExpiration(Duration.ofMinutes(10)))
                                              .withService(WriteBehindConfigurationBuilder.newUnBatchedWriteBehindConfiguration()
                                                                  .queueSize(10)
                                                                  .concurrencyLevel(10).build()))
                                              .build();
    cacheManager.init();
    
    bug in progress 
    opened by arpitmalhotra 6
Releases(v3.10.0)
TransitScheduler - a command line tool that can read .json data formulated for tracking transit patterns to a multithreaded concurrent simulation of passengers boarding and unboarding trains that constantly move to the next station on the line. The trick here, is that two trains cannot occupy the same station at any time.

TransitScheduler - a command line tool that can read .json data formulated for tracking transit patterns to a multithreaded concurrent simulation of passengers boarding and unboarding trains that constantly move to the next station on the line. The trick here, is that two trains cannot occupy the same station at any time.

Emmet Hayes 1 Dec 2, 2022
Java annotation-based framework for parsing Git like command line structures

Airline Airline is a Java annotation-based framework for parsing Git like command line structures. Latest release is 0.8, available from Maven Central

null 847 Nov 26, 2022
A command line parser generator

jbock is a command line parser that works similar to airline and picocli. While most of these other tools scan for annotations at runtime, jbock is an

H90 73 Dec 13, 2022
Command line parsing framework for Java

JCommander This is an annotation based parameter parsing framework for Java 8. Here is a quick example: public class JCommanderTest { @Parameter

Cedric Beust 1.8k Dec 29, 2022
The SDKMAN! Command Line Interface

SDKMAN! CLI The Software Development Kit Manager Command Line Interface SDKMAN is a tool for managing parallel Versions of multiple Software Developme

SDKMAN! 5k Jan 4, 2023
Java monitoring for the command-line, profiler included

jvmtop is a lightweight console application to monitor all accessible, running jvms on a machine. In a top-like manner, it displays JVM internal metri

null 1.2k Jan 6, 2023
Command-line API for Atlassian JIRA using the Tomitribe CREST library

Atlassian JIRA Command-Line (CLI) Jamira is a command-line API for Atlassian JIRA using the Tomitribe CREST library. Installation Jamira can be downlo

Tomitribe 12 Sep 10, 2022
A command line client for Kafka Connect

kcctl -- A CLI for Apache Kafka Connect This project is a command-line client for Kafka Connect. Relying on the idioms and semantics of kubectl, it al

Gunnar Morling 274 Dec 19, 2022
A command line client for Kafka Connect

?? kcctl – Your Cuddly CLI for Apache Kafka Connect This project is a command-line client for Kafka Connect. Relying on the idioms and semantics of ku

kcctl 274 Dec 19, 2022
Command-line and graphical implementations of 2048 game and solvers.

2048 This is a simple 2048 game implemented both as a command-line interface and a graphical Java applet, with a couple of basic auto-solving algorith

Radon Rosborough 4 Sep 25, 2022
A maven plugin to include features from jmeter-plugins.org for JMeterPluginsCMD Command Line Tool to create graphs, export csv files from jmeter result files and Filter Result tool.

jmeter-graph-tool-maven-plugin A maven plugin to create graphs using the JMeter Plugins CMDRunner from JMeter result files (*.jtl or *.csv) or using F

Vincent DABURON 6 Nov 3, 2022
DeV Tools - Swiss Army Knife of command line utilities

dvt aims to bundle all small utilities used by developers (typically a mix of cli and online tools) into one binary that you can simply use in the console. No need for complex pipe-ing, copy-pasting on different sites or keep installing cli utilities for every need.

Madalin Ilie 13 Sep 15, 2022
Command Line Interface to interact with Carbyne Stack Virtual Clouds

Carbyne Stack Command Line Interface This is a CLI tool to communicate with the Carbyne Stack services. DISCLAIMER: The Carbyne Stack CLI is alpha sof

Carbyne Stack 5 Oct 15, 2022
A command-line tool to securely encrypt passwords and notes using AES encryption.

Treasury A command-line tool to securely encrypt passwords and notes using AES encryption. Installation Usage Technology Built solely in Java Picocli

Kai 4 Oct 17, 2022
A library for off-line inverse geocoding that supports location up to district level

jetgeo 是一个用于离线逆地理编码的库,支持转换位置到县/地区级别, 通过它你可以消耗一定的内存以换取一个内存级别的转换。主要适用于精度要求不高的一些服务端场景。 如果你需要一个精确定位的场景,那么它可能并不合适,此时你可能需要适用地理位置信息提供商的一些服务, 但他们往往有次数限制或者需要支付

linG 6 Aug 25, 2022
Text Object Java Objects (TOJOs): an object representation of a multi-line structured text file like CSV

It's a simple manager of "records" in a text file of CSV, JSON, etc. format. It's something you would use when you don't want to run a full database,

Yegor Bugayenko 19 Dec 27, 2022
JDK main-line development

Welcome to the JDK! For build instructions please see the online documentation, or either of these files: doc/building.html (html version) doc/buildin

OpenJDK 14.8k Dec 29, 2022