{"id":16367160,"url":"https://github.com/snower/jaslock-spring","last_synced_at":"2026-02-21T15:30:16.210Z","repository":{"id":251308655,"uuid":"814058473","full_name":"snower/jaslock-spring","owner":"snower","description":"jaslock spring boot support","archived":false,"fork":false,"pushed_at":"2024-09-13T01:31:04.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-24T22:33:14.997Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-12T09:04:58.000Z","updated_at":"2024-09-13T01:31:07.000Z","dependencies_parsed_at":"2024-09-12T19:30:31.792Z","dependency_job_id":null,"html_url":"https://github.com/snower/jaslock-spring","commit_stats":null,"previous_names":["snower/jaslock-spring"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fjaslock-spring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fjaslock-spring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fjaslock-spring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snower%2Fjaslock-spring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snower","download_url":"https://codeload.github.com/snower/jaslock-spring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239850437,"owners_count":19707350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T02:48:46.002Z","updated_at":"2026-02-21T15:30:16.167Z","avatar_url":"https://github.com/snower.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jaslock-spring\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/snower/jaslock/build-test.yml?label=tests)](https://github.com/snower/jaslock-spring/actions/workflows/build-test.yml)\n[![GitHub Repo stars](https://img.shields.io/github/stars/snower/jaslock-spring?style=social)](https://github.com/snower/jaslock-spring/stargazers)\n\nHigh-performance distributed sync service and atomic DB. Provides good multi-core support through lock queues, high-performance asynchronous binary network protocols. Can be used for spikes, synchronization, event notification, concurrency control. https://github.com/snower/slock\n\n# Install\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.snower\u003c/groupId\u003e\n    \u003cartifactId\u003ejaslock-spring-boot-starter\u003c/artifactId\u003e\n    \u003cversion\u003e0.1.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n# Configuration\n\n```yaml\nspring:\n  slock:\n    enabled: true # 是否启用，默认是\n    # 连接URL\n    #url: 'slock://127.0.0.1:5658,127.0.0.1:5659/?database=0\u0026executorWorkerCount=1\u0026executorMaxWorkerCount=2\u0026executorMaxCapacity=2147483647\u0026executorWorkerKeepAliveTime=7200\u0026defaultTimeoutFlag=0\u0026defaultExpriedFlag=0'\n    host: '127.0.0.1' # 连接Host\n    port: 5658  # 连接端口\n    #hosts: 127.0.0.1:5658,127.0.0.1:5659 # 集群连接Host列表\n    # databaseId: 0 # 连接DB\n    # executor: # 异步执行线程池配置\n    #   workerCount: 1 # 异步执行线程池核心线程数\n    #   maxWorkerCount: 2 # 异步执行线程池最大线程数\n    #   maxCapacity: 2147483647 # 异步执行线程池最大任务数量\n    #   workerKeepAliveTime: 7200 # 异步执行线程池KeepAlive时间\n    #   workerKeepAliveTimeUnit: 'seconds' # 异步执行线程池KeepAlive单位\n    # defaultTimeoutFlag: 0 # 默认超时时间Flag\n    # defaultExpriedFlag: 0 # 默认过期时间Flag\n```\n\n# Useage\n\n## Aspect Annotation\n\n#### Lock 加锁\n\n```java\n@Target({ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\npublic @interface Lock {\n    @AliasFor(\"key\")\n    String value() default \"\";\n\n    @AliasFor(\"value\")\n    String key() default \"\"; // 加锁Key，支持spel表达式\n\n    int timeout() default 5; // 等待超时时间\n\n    int expried() default 120; // 过期时间\n\n    byte databaseId() default -1; // 使用DB，-1使用全局配置\n\n    Class\u003c? extends Exception\u003e timeoutException() default LockTimeoutException.class; // 超时抛出异常类型\n\n    Class\u003c? extends Exception\u003e exception() default SlockException.class; // 抛出其它异常类型\n}\n```\n\n#### MaxConcurrentFlow 最大并发限流\n\n```java\n@Target({ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\npublic @interface MaxConcurrentFlow {\n    @AliasFor(\"key\")\n    String value() default \"\";\n\n    @AliasFor(\"value\")\n    String key() default \"\"; // 限流Key，支持spel表达式\n\n    short count() default 64; // 限流最大并发数\n\n    int timeout() default 60; // 等待超时时间\n\n    int expried() default 120; // 过期时间\n\n    byte databaseId() default -1; // 使用DB，-1使用全局配置\n\n    Class\u003c? extends Exception\u003e timeoutException() default LockTimeoutException.class; // 超时抛出异常类型\n\n    Class\u003c? extends Exception\u003e exception() default SlockException.class; // 抛出其它异常类型\n}\n```\n\n#### TokenBucketFlow 令牌桶限流\n\n```java\n@Target({ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\npublic @interface TokenBucketFlow {\n    @AliasFor(\"key\")\n    String value() default \"\";\n\n    @AliasFor(\"value\")\n    String key() default \"\"; // 限流Key，支持spel表达式\n\n    short count() default 64; // 令牌数\n\n    int timeout() default 60; // 加锁等待超时时间\n\n    double period() default 0.1; // 过期周期，单位秒\n\n    byte databaseId() default -1; // 使用DB，-1使用全局配置\n\n    Class\u003c? extends Exception\u003e timeoutException() default LockTimeoutException.class; // 超时抛出异常类型\n\n    Class\u003c? extends Exception\u003e exception() default SlockException.class; // 抛出其它异常类型\n}\n```\n\n#### Idempotent 幂等\n\n```java\n@Target({ElementType.METHOD})\n@Retention(RetentionPolicy.RUNTIME)\n@Documented\npublic @interface Idempotent {\n    @AliasFor(\"key\")\n    String value() default \"\";\n\n    @AliasFor(\"value\")\n    String key() default \"\"; // 幂等Key，支持spel表达式\n\n    int timeout() default 5; // 加锁等待超时时间\n\n    int expried() default 300; // 加锁过期时间\n\n    byte databaseId() default -1; // 使用DB，-1使用全局配置\n\n    Class\u003c? extends Exception\u003e timeoutException() default LockTimeoutException.class; // 超时抛出异常类型\n\n    Class\u003c? extends Exception\u003e exception() default SlockException.class; // 抛出其它异常类型\n}\n```\n\n## EventFuture\n\n分布式Event Future，用于等待及获取远程异步结果。\n\n```java\npackage main;\n\nimport io.github.snower.jaslock.exceptions.SlockException;\nimport io.github.snower.jaslock.spring.boot.EventFuture;\nimport io.github.snower.jaslock.spring.boot.SlockTemplate;\nimport io.github.snower.jaslock.spring.boot.SlockConfiguration;\nimport io.github.snower.jaslock.spring.boot.SlockSerializater;\n\nimport java.io.IOException;\nimport java.util.concurrent.ExecutionException;\nimport java.util.concurrent.TimeUnit;\nimport java.util.concurrent.TimeoutException;\n\npublic class App {\n    public static void main(String[] args) throws SlockException, IOException, ExecutionException, InterruptedException {\n        SlockTemplate slockTemplate = new SlockTemplate(SlockConfiguration.newBuilder()\n                .build(), new SlockSerializater.ObjectSerializater());\n        EventFuture\u003cString\u003e eventFuture = slockTemplate.newEventFuture(\"testEventFuture\");\n        eventFuture.setResult(\"Test\");\n        eventFuture = slockTemplate.newEventFuture(\"testEventFuture\");\n        org.junit.Assert.assertEquals(eventFuture.get(), \"Test\");\n        eventFuture.close();\n        eventFuture = slockTemplate.newEventFuture(\"testEventFuture\");\n        try {\n            org.junit.Assert.assertNull(eventFuture.get(0, TimeUnit.SECONDS));\n            throw new SlockException();\n        } catch (TimeoutException e) {\n        }\n    }\n}\n```\n\n# License\n\nslock uses the MIT license, see LICENSE file for the details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fjaslock-spring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnower%2Fjaslock-spring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnower%2Fjaslock-spring/lists"}