feat: ing...
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1,3 +1,9 @@
|
||||
commons-cache.ipr
|
||||
commons-cache.iml
|
||||
commons-cache.iws
|
||||
build/
|
||||
.gradle/
|
||||
|
||||
# ---> Java
|
||||
# Compiled class file
|
||||
*.class
|
||||
@@ -31,7 +37,8 @@ replay_pid*
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
69
build.gradle
Normal file
69
build.gradle
Normal file
@@ -0,0 +1,69 @@
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'idea'
|
||||
|
||||
def baseProjectName = 'commons-cache-1.0'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
def addRepo = new File(System.getProperty("user.home"), ".build_add.repo")
|
||||
|
||||
repositories {
|
||||
//mavenCentral()
|
||||
flatDir { dirs "${System.env.JAVA_HOME}/jre/lib" }
|
||||
flatDir { dirs "${System.env.JAVA_HOME}/lib" }
|
||||
maven {
|
||||
url 'https://maven.aliyun.com/repository/central'
|
||||
}
|
||||
if (addRepo.exists()) { maven() { url addRepo.text.trim() } }
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
// '-x test' skip unit test
|
||||
defaultTasks 'packjar'
|
||||
|
||||
task packjarsrc {
|
||||
doLast {
|
||||
ant.jar(destfile: "${baseProjectName}-sources.jar") {
|
||||
fileset(dir: 'src/main/java', includes: '**/*.java')
|
||||
}
|
||||
}
|
||||
}
|
||||
packjarsrc.dependsOn build
|
||||
|
||||
task packjar {
|
||||
doLast {
|
||||
def packtempclasses = "packtempclasses"
|
||||
def libs = ant.path {
|
||||
fileset(dir: 'build/libs', includes: '*.jar')
|
||||
}
|
||||
libs.list().each {
|
||||
ant.unzip(dest: packtempclasses, src: it)
|
||||
}
|
||||
new File(packtempclasses + "/commons-jar-version-build.txt").write(new Date().format("yyyyMMdd"), "UTF-8")
|
||||
ant.jar(destfile: "${baseProjectName}.jar") {
|
||||
fileset(dir: packtempclasses, includes: '**/*.*')
|
||||
}
|
||||
ant.delete(dir: packtempclasses)
|
||||
}
|
||||
}
|
||||
packjar.dependsOn packjarsrc
|
||||
|
||||
dependencies {
|
||||
implementation files(fileTree(dir: 'lib', includes: ['*.jar'], excludes: ['*-sources.jar', '*-javadoc.jar']))
|
||||
|
||||
def buildJSON = new JsonSlurper().parseText(new File("build.json").text)
|
||||
if (buildJSON.repo != null && buildJSON.repo.dependencies != null) {
|
||||
buildJSON.repo.dependencies.each {
|
||||
implementation("${it}")
|
||||
}
|
||||
}
|
||||
|
||||
testImplementation 'junit:junit:4.13.1'
|
||||
}
|
||||
|
||||
17
build.json
Normal file
17
build.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"java": "1.8",
|
||||
"builder": {
|
||||
"name": "gradle",
|
||||
"version": "7.0"
|
||||
},
|
||||
"repo": {
|
||||
"gid": "me.hatter",
|
||||
"aid": "commons-cache",
|
||||
"jar": "commons-cache-1.0.jar",
|
||||
"src": "commons-cache-1.0-sources.jar",
|
||||
"dependencies": [
|
||||
"me.hatter:commons:4.29",
|
||||
"redis.clients:jedis:7.1.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
22
justfile
Normal file
22
justfile
Normal file
@@ -0,0 +1,22 @@
|
||||
_:
|
||||
@just --list
|
||||
|
||||
alias b:=build
|
||||
alias pub:=publish
|
||||
alias i:=ide
|
||||
|
||||
# init for IDEA
|
||||
ide:
|
||||
buildj idea
|
||||
|
||||
# build commons
|
||||
build:
|
||||
buildj clean
|
||||
buildj
|
||||
|
||||
# build and publish commons
|
||||
publish: build
|
||||
hatter repo publish
|
||||
|
||||
|
||||
|
||||
15
src/main/java/me/hatter/tools/commons/cache/TestMain.java
vendored
Normal file
15
src/main/java/me/hatter/tools/commons/cache/TestMain.java
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
package me.hatter.tools.commons.cache;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class TestMain {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final Jedis jedis = new Jedis("127.0.0.1", 6379);
|
||||
|
||||
// jedis.connect();
|
||||
jedis.set("a", "test");
|
||||
String v = jedis.get("a");
|
||||
System.out.println(v);
|
||||
}
|
||||
}
|
||||
17
src/main/java/me/hatter/tools/commons/cache/annotation/CacheObject.java
vendored
Normal file
17
src/main/java/me/hatter/tools/commons/cache/annotation/CacheObject.java
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
package me.hatter.tools.commons.cache.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface CacheObject {
|
||||
long ttl() default 60;
|
||||
|
||||
long longTermTtl() default 60 * 24;
|
||||
|
||||
TimeUnit unit() default TimeUnit.MINUTES;
|
||||
}
|
||||
6
src/main/java/me/hatter/tools/commons/cache/resolver/CacheResolver.java
vendored
Normal file
6
src/main/java/me/hatter/tools/commons/cache/resolver/CacheResolver.java
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
package me.hatter.tools.commons.cache.resolver;
|
||||
|
||||
public interface CacheResolver<T> {
|
||||
|
||||
T resolve();
|
||||
}
|
||||
Reference in New Issue
Block a user