All Projects → mini188 → j2cache

mini188 / j2cache

Licence: Apache-2.0 license
java实现的缓存策略组件,支持多种缓存产品,开发人员可以像Map一样使用,简单方便。支持的存储方案:jvm\redis\ignite\hazelcast\guava

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to j2cache

delta
DDD-centric event-sourcing library for the JVM
Stars: ✭ 15 (-54.55%)
Mutual labels:  jvm, hazelcast
hazelcast-csharp-client
Hazelcast .NET Client
Stars: ✭ 98 (+196.97%)
Mutual labels:  hazelcast
jstackSeries.sh
Script for capturing a series of thread dumps from a Java process using jstack (on Linux and Windows)
Stars: ✭ 28 (-15.15%)
Mutual labels:  jvm
Cojen
Java bytecode generation and disassembly tools
Stars: ✭ 28 (-15.15%)
Mutual labels:  jvm
java-perf-workshop
Guided walkthrough to understand the performance aspects of a Java web service
Stars: ✭ 53 (+60.61%)
Mutual labels:  jvm
aot
Russian morphology for Java
Stars: ✭ 41 (+24.24%)
Mutual labels:  jvm
sconfig
Scala configuration library supporting HOCON for Scala, Java, Scala.js, and Scala Native
Stars: ✭ 99 (+200%)
Mutual labels:  jvm
hprof-slurp
JVM heap dump analyzer
Stars: ✭ 65 (+96.97%)
Mutual labels:  jvm
java-manta
Java Manta Client SDK
Stars: ✭ 16 (-51.52%)
Mutual labels:  jvm
SmallVM
TODO: A small and lightweight Java Virtual Machine
Stars: ✭ 23 (-30.3%)
Mutual labels:  jvm
openwhisk-runtime-java
Apache OpenWhisk Runtime Java supports Apache OpenWhisk functions written in Java and other JVM-hosted languages
Stars: ✭ 43 (+30.3%)
Mutual labels:  jvm
styx
Programmable, asynchronous, event-based reverse proxy for JVM.
Stars: ✭ 250 (+657.58%)
Mutual labels:  jvm
jacobin
A more than minimal JVM written in Go and capable of running Java 17 classes.
Stars: ✭ 59 (+78.79%)
Mutual labels:  jvm
dragome-sdk
Dragome is a tool for creating client side web applications in pure Java (JVM) language.
Stars: ✭ 79 (+139.39%)
Mutual labels:  jvm
JavaHub
Java程序员学习之路,持续更新原创内容,欢迎Star
Stars: ✭ 27 (-18.18%)
Mutual labels:  jvm
java2typescript
Java Processor to generate Typescript Definition from Java classes - This is to help developing on JVM javascript engine (ie Nashorn) using Typescript
Stars: ✭ 24 (-27.27%)
Mutual labels:  jvm
play-scala-compile-di-example
Example Play Project using compile time dependency injection and Play WS with ScalaTest
Stars: ✭ 37 (+12.12%)
Mutual labels:  jvm
play-java-chatroom-example
Example Chatroom with Java API
Stars: ✭ 33 (+0%)
Mutual labels:  jvm
hface
look your Hazelcast cluster in the face!
Stars: ✭ 73 (+121.21%)
Mutual labels:  hazelcast
londogard-nlp-toolkit
Londogard Natural Language Processing Toolkit written in Kotlin
Stars: ✭ 49 (+48.48%)
Mutual labels:  jvm

j2cache

在系统中经常会用缓存以提供更好的性能,缓存主要的数据结构也只是K-V。对于一些早期产品使用haspmap作为缓存,随着发展需要分布式部署,那么就会遇到分布式缓存的问题,自然就要使用redis/memcached之类的产品,但每一种产品都有自己一套的接口或者SDK,开发人员使用的时候需要专门改写代码才能使用。使用j2cache就可以简单的实现这种切换,j2cache实现了Map接口可以更友好的切换旧代码,这对于开发人员来说是透明的。

说明

本项目代码未经过大型项目的验证,更像是一个实验性质的项目,不建议直接在生产环境或者商业项目上直接使用,如果需在实际的项目中使用建议做好充分的测试。

另外,代码中集成了多个缓存策略的组件,在实际使用中对于不需要的删除掉相关的jar依赖和策略即可。比如只使用redis方案,那么iginte和hazelcast以及guava localcache都可以清除,可以大幅减少包的引用。

主要特点

  1. 针对K-V缓存提供一种扩展的思路,并且统一缓存的访问接口,开发人员可以在系统中灵活的指定缓存的产品,也可以新增其他的缓存产品。

  2. 创建缓存时指定缓存的策略,从而实现多种策略同时在代码中并存,比如开发人员可以在仅需要本地内存时指定本地缓存策略,如果分布式缓存时指定相应策略即可。

  3. 可以设置缓存有效期,解决hashmap之类无法通过有效期淘汰缓存的问题

为此项目中实现的存储方案:

  • jvm(ConcurrentHashMap)
  • redis
  • iginte
  • hazelcast (add 2016-10-13)
  • guava localcache(add 2020-08-25)

每种缓存策略都对应一种KV软件产品/组件,其中jvm/guava都是本地缓存策略,redis/iginte/hazelcast是分布式缓存。

未来想法

  • CacheManager支持分布式
  • 支持指标统计

使用方法示例:

public static void main(String[] args) {
	try {
		ICache<String, String> cache = CacheManager.getOrCreateCache(DefaultCacheStategy.class.getName(), "jvmCache", String.class, String.class);
		cache.put("key1", new Date().toString());
		
		String v = cache.get("key1");
		System.err.println("cache value: " +v);
	} catch (Exception e) {
		e.printStackTrace();
	}
}

另外可以参考src/test/java 下的测试代码

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].