1 /*
2 * Copyright 2010-2026 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.mybatis.caches.ehcache;
17
18 /**
19 * Cache implementation backed by Ehcache 3 that provides basic blocking semantics.
20 * <p>
21 * In Ehcache 2 this class used {@code BlockingCache} to acquire per-key locks and prevent cache stampedes. Ehcache 3
22 * does not provide an equivalent decorator, so blocking must be provided by the caller (e.g. by wrapping this cache
23 * with {@link org.apache.ibatis.cache.decorators.BlockingCache}).
24 * </p>
25 *
26 * @author Iwao AVE!
27 */
28 public class EhBlockingCache extends AbstractEhcacheCache {
29
30 /**
31 * Instantiates a new eh blocking cache.
32 *
33 * @param id
34 * the id
35 */
36 public EhBlockingCache(final String id) {
37 super(id);
38 }
39
40 @Override
41 public Object removeObject(Object key) {
42 // this method is called during a rollback to release any previously acquired lock;
43 // removing the entry is the correct action for Ehcache 3 (null values are not supported).
44 return super.removeObject(key);
45 }
46
47 }