dtcache

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

License

License

GroupId

GroupId

org.naike
ArtifactId

ArtifactId

dtcache
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

dtcache
Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/sxwailyc/dtcache

Download dtcache

How to add to project

<!-- https://jarcasting.com/artifacts/org.naike/dtcache/ -->
<dependency>
    <groupId>org.naike</groupId>
    <artifactId>dtcache</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.naike/dtcache/
implementation 'org.naike:dtcache:1.0'
// https://jarcasting.com/artifacts/org.naike/dtcache/
implementation ("org.naike:dtcache:1.0")
'org.naike:dtcache:jar:1.0'
<dependency org="org.naike" name="dtcache" rev="1.0">
  <artifact name="dtcache" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.naike', module='dtcache', version='1.0')
)
libraryDependencies += "org.naike" % "dtcache" % "1.0"
[org.naike/dtcache "1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
redis.clients : jedis jar 2.8.0
commons-logging : commons-logging jar 1.2

Project Modules

There are no modules declared in this project.

dtcache, a local cache support data sync for distributed application


config the cache(only need call once)

    	CacheItemListener cacheItemListener = new CacheItemListenerRedisImpl() {

			@Override
			public Jedis getRedis() {
				return redis.getResource();
			}

			@Override
			public void closeRedis(Jedis jedis) {
				redis.returnResource(jedis);
			}
		};

		CacheConfig config = new CacheConfig.Builder().cacheItemListener(cacheItemListener).build();
        LocalCache.start(config);

example

write

Cache cache = new LocalCache();
User user = new User();
user.setUserId("userId");
user.setUsername("username");
cache.put(user.getUserId(), user);

read

Cache cache = new LocalCache();
User user = cache.get("userId", User.class);

delete

Cache cache = new LocalCache();
cache.delete(User.class, "userId);

Versions

Version
1.0