micro-cache-grid

Distributed java cache for micro service based systems using apache ignite data grid

License

License

GroupId

GroupId

com.github.itzmedinesh
ArtifactId

ArtifactId

micro-cache-grid
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

pom
Description

Description

micro-cache-grid
Distributed java cache for micro service based systems using apache ignite data grid
Project URL

Project URL

https://github.com/itzmedinesh/micro-cache-grid.git
Source Code Management

Source Code Management

https://github.com/itzmedinesh/micro-cache-grid

Download micro-cache-grid

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.itzmedinesh/micro-cache-grid/ -->
<dependency>
    <groupId>com.github.itzmedinesh</groupId>
    <artifactId>micro-cache-grid</artifactId>
    <version>1.0.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.itzmedinesh/micro-cache-grid/
implementation 'com.github.itzmedinesh:micro-cache-grid:1.0.0'
// https://jarcasting.com/artifacts/com.github.itzmedinesh/micro-cache-grid/
implementation ("com.github.itzmedinesh:micro-cache-grid:1.0.0")
'com.github.itzmedinesh:micro-cache-grid:pom:1.0.0'
<dependency org="com.github.itzmedinesh" name="micro-cache-grid" rev="1.0.0">
  <artifact name="micro-cache-grid" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.github.itzmedinesh', module='micro-cache-grid', version='1.0.0')
)
libraryDependencies += "com.github.itzmedinesh" % "micro-cache-grid" % "1.0.0"
[com.github.itzmedinesh/micro-cache-grid "1.0.0"]

Dependencies

compile (8)

Group / Artifact Type Version
javax.inject : javax.inject jar 1
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.6.3
com.fasterxml.jackson.core : jackson-databind jar 2.6.3
javax.cache : cache-api jar 1.0.0
org.apache.ignite : ignite-core jar 1.6.0
commons-collections : commons-collections jar 3.2.2
org.apache.commons : commons-lang3 jar 3.4
log4j : log4j jar 1.2.17

Project Modules

There are no modules declared in this project.

micro-cache-grid

Distributed java cache for micro service based systems using apache ignite data grid

Versions on maven

http://central.maven.org/maven2/com/github/itzmedinesh/micro-cache-grid/

Sample YAML configuration


cache.grid:
  grid.name: "ServiceCacheGrid"
  grid.hostname: "127.0.0.1"
  grid.communication.port: 47100
  grid.discovery.port: 47500
  grid.metricslog.frequency: 0
  grid.cache:
    TPNB_CATID_MAPPING:
      cache.mode: "LOCAL"
      cache.expirypolicy: "TOUCHED"
      cache.expiryduration: "ONE_MINUTE"
      cache.readthrough: true
      cache.management.enabled: false
      cache.evictionpolicy: "FIRST_IN_FIRST_OUT"
      cache.maxsize: 4
      cache.loader.class: "com.itzmeds.cache.loader.SampleCacheLoader"
      cache.loader.class.parameters:
      -
        service.type: "com.fasterxml.jackson.databind.ObjectMapper"
    TPNB_CATID_MAPPING_V2:
      cache.mode: "LOCAL"
      cache.expirypolicy: "MODIFIED"
      cache.expiryduration: "ONE_MINUTE"
      cache.readthrough: false
      cache.management.enabled: false
      cache.evictionpolicy: "FIRST_IN_FIRST_OUT"
      cache.maxsize: 4
      cache.loader.class: "com.itzmeds.cache.loader.SampleCacheLoader"
      cache.loader.class.parameters:
      -
        service.type: "com.fasterxml.jackson.databind.ObjectMapper"

Initialization of apache ignite cache grid and creation of cache access template


CacheGridConfigurator.configureIgniteDataGrid(testConfiguration.getCacheGridConfig());

Use when cache loader class constructor has arguments that needs to be fetched from factory classes or DI containers 

CacheGridConfigurator.configureIgniteDataGrid(testConfiguration.getCacheGridConfig(), new ServiceFactoryTestImpl());

CacheTemplate<String> cacheTemplate = CacheGridConfigurator.getCacheLookupTemplate("TPNB_CATID_MAPPING");

lookup, insert or delete from cache using cache template


Single value lookup

	cacheTemplate.lookup("key1")
	
Multiple values lookup	

	Set<String> keys = new HashSet<String>();
	keys.add("key1");
	keys.add("key2");
	
	Assert.assertEquals(keys.size(), cacheTemplate.lookup(keys).size());

Insert or update single key-value pair

	cacheTemplate.insertOrUpdate("key1000", "value1000");

Insert or update set of key-value pairs

	Map<String, String> keysList = new HashMap<String, String>();
	keysList.put("key45", "value45");
	keysList.put("key46", "value46");
	
	cacheTemplate.insertOrUpdate(keysList);	
									

Note: Refer 'com.itzmeds.cache.loader.SampleCacheLoader' for sample read through cache loader implementation

Versions

Version
1.0.0