Cacheonix:Java分散式叢集快取框架
本文由碼農網 – 小峰原創,轉載請看清文末的轉載要求,歡迎參與我們的付費投稿計劃!
記得之前分享過的一款Java分散式快取系統Ehcache,可以有效地減輕資料庫的讀寫負擔,提高Web系統的吞吐率。這次介紹的Cacheonix同樣也是一個基於Java的分散式叢集快取系統,它同樣可以幫助你實現分散式快取的部署。
Cacheonix的特點
- 可靠的分散式 Java 快取
- 通過複製實現高可用性
- 支援泛型的快取 API
- 可與 ORM 框架整合
- 使用資料分割槽實現負載均衡
- 支援非多播網路
- 高效能運算
- 快速的本地 Java 快取
- 分散式鎖機制
Cacheonix的架構圖
Cacheonix分散式快取XML配置
<?xml version ="1.0"?> <cacheonix xmlns="http://www.cacheonix.com/schema/configuration" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cacheonix.com/schema/configuration http://www.cacheonix.com/schema/cacheonix-config-2.0.xsd"> <server> <listener> <tcp port="8879" buffer="128k"/> </listener> <broadcast> <multicast multicastAddress="225.0.1.2" multicastPort="9998" multicastTTL="0"/> </broadcast> <partitionedCache name="customer.cache"> <store> <lru maxElements="10000" maxBytes="10mb"/> <expiration idleTime="120s"/> </store> </partitionedCache> <partitionedCache name="invoice.cache"> <store> <lru maxElements="10000" maxBytes="10mb"/> <expiration idleTime="120s"/> </store> </partitionedCache> <partitionedCache name="search.results.cache"> <store> <lru maxBytes="5mb"/> </store> </partitionedCache> </server> </cacheonix>
Cacheonix快取的存取
從配置中獲取Cacheonix例項
/** * Tester for CacheManager. */ public final class CacheonixTest extends TestCase { private Cacheonix cacheonix; /** * Tests getting an instance of CacheManager using a default Cacheonix configuration. */ public void testGetInstance() { assertNotNull("Cacheonix created in setUp() method should not be null", cacheonix); } /** * Sets up the fixture. This method is called before a test is executed. * <p/> * Cacheonix receives the default configuration from a <code>cacheonix-config.xml</code> found in a class path or * using a file that name is defined by system parameter <code>cacheonix.config.xml<code>. */ protected void setUp() throws Exception { super.setUp(); // Get Cacheonix using a default Cacheonix configuration. The configuration // is stored in the conf/cacheonix-config.xml cacheonix = Cacheonix.getInstance(); } /** * Tears down the fixture. This method is called after a test is executed. */ protected void tearDown() throws Exception { // Cache manager has be be shutdown upon application exit. // Note that call to shutdown() here uses unregisterSingleton // set to true. This is necessary to support clean restart on setUp() cacheonix.shutdown(ShutdownMode.GRACEFUL_SHUTDOWN, true); cacheonix = null; super.tearDown(); } }
讀取快取
Cacheonix cacheonix = Cacheonix.getInstance(); Cache<String, String> cache = cacheonix.getCache("my.cache"); String cachedValue = cache.get("my.key");
設定快取
Cacheonix cacheonix = Cacheonix.getInstance(); Cache<String, String> cache = cacheonix.getCache("my.cache"); String replacedValue = cache.put("my.key", "my.value");
刪除快取
Cacheonix cacheonix = Cacheonix.getInstance(); Cache<String, String> cache = cacheonix.getCache("my.cache"); String removedValue = cache.remove("my.key");
Cacheonix作為一款開源的分散式快取框架,可以滿足中型企業規模的系統架構,對提升系統效能有非常棒的作用。
本文連結:http://www.codeceo.com/article/java-cacheonix.html
本文作者:碼農網 – 小峰
[ 原創作品,轉載必須在正文中標註並保留原文連結和作者等資訊。]
相關文章
- LNMP 分散式叢集(四):Memcached 快取伺服器的搭建LNMP分散式快取伺服器
- Spring Boot整合Hazelcast實現叢集與分散式記憶體快取Spring BootAST分散式記憶體快取
- 用Java寫一個分散式快取——快取管理Java分散式快取
- JAVA中使用最廣泛的本地快取?Ehcache的自信從何而來3 —— 本地快取變身分散式叢集快取,打破本地快取天花板Java快取分散式
- ElasticSearch 分散式叢集Elasticsearch分散式
- Hadoop框架:叢集模式下分散式環境搭建Hadoop框架模式分散式
- 分散式快取分散式快取
- HDFS分散式叢集搭建分散式
- golang分散式與叢集Golang分散式
- hadoop分散式叢集搭建Hadoop分散式
- elasticsearch(三)---分散式叢集Elasticsearch分散式
- HA分散式叢集搭建分散式
- 聊聊分散式快取分散式快取
- 分散式快取方案分散式快取
- redis→分散式快取Redis分散式快取
- 聊聊本地快取和分散式快取快取分散式
- Redis快取高可用叢集Redis快取
- 用Java寫一個分散式快取——快取淘汰演算法Java分散式快取演算法
- Hadoop完全分散式叢集配置Hadoop分散式
- Hadoop分散式叢集搭建_1Hadoop分散式
- 叢集和分散式區別分散式
- 分散式快取NCache使用分散式快取
- SmartSql Redis 分散式快取SQLRedis分散式快取
- 分散式快取擊穿分散式快取
- Redis——快取穿透、快取擊穿、快取雪崩、分散式鎖Redis快取穿透分散式
- 分散式快取 - 快取簡介,常用快取演算法分散式快取演算法
- ray-分散式計算框架-叢集與非同步Job管理分散式框架非同步
- Citus 分散式 PostgreSQL 叢集 - SQL Reference(攝取、修改資料 DML)分散式SQL
- Mongodb分散式叢集副本集+分片MongoDB分散式
- k04_分散式快取分散式快取
- 分散式快取基礎教程分散式快取
- 雲上的分散式快取分散式快取
- 分散式快取 - 概念解釋分散式快取
- 分散式之快取擊穿分散式快取
- 分散式系統快取系列一 認識快取分散式快取
- 從快取到分散式快取的那些事快取分散式
- 用Java寫一個分散式快取——RESP服務端Java分散式快取服務端
- Citus 分散式 PostgreSQL 叢集 - SQL Reference(查詢分散式表 SQL)分散式SQL
- MongoDB中的分散式叢集架構MongoDB分散式架構