feat: ing...

This commit is contained in:
2026-01-02 13:28:56 +08:00
parent 9ab9dad8d3
commit 0198d9c973
7 changed files with 154 additions and 1 deletions

9
.gitignore vendored
View File

@@ -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
View 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
View 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
View 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

View 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);
}
}

View 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;
}

View File

@@ -0,0 +1,6 @@
package me.hatter.tools.commons.cache.resolver;
public interface CacheResolver<T> {
T resolve();
}