项目作者: gabber12

项目描述 :
Dropwizard bundle for Caffeine cache bootstrapping
高级语言:
项目地址: git://github.com/gabber12/dropwizard-caffeine-configurator.git
创建时间: 2018-01-29T16:08:47Z
项目社区:https://github.com/gabber12/dropwizard-caffeine-configurator

开源协议:Apache License 2.0

下载


Dropwizard caffeine configurator Build Status

Dropwizard bundle for Caffeine cache bootstrapping

Dependencies

Usage

The bundle simplifies caffeine spec mangement and also integrates with dropwizard metrics registry.

Build instructions

  • Clone the source:

    1. git clone github.com/gabber12/dropwizard-caffeine-configurator
  • Build

    1. mvn install

Maven Dependency

Use the following repository:

  1. <repository>
  2. <id>clojars</id>
  3. <name>Clojars repository</name>
  4. <url>https://clojars.org/repo</url>
  5. </repository>

Use the following maven dependency:

  1. <dependency>
  2. <groupId>io.dropwizard.cache</groupId>
  3. <artifactId>caffeine-configurator</artifactId>
  4. <version>1.0.0-SNAPSHOT</version>
  5. </dependency>

Using Configurator bundle

Bootstrap

  1. private final CaffeineBundle caffeineBundle = new CaffeineBundle<CacheNames, AppConfiguration>() {
  2. @Override
  3. public CaffeineConfig getConfig(AppConfiguration configuration) {
  4. return configuration.getCacheConfig();
  5. }
  6. };
  7. ...
  8. @Override
  9. public void initialize(Bootstrap<?> bootstrap) {
  10. bootstrap.addBundle(caffeineBundle);
  11. }
  12. public enum CacheNames {
  13. FIRST_CACHE
  14. }

Get a loading Cache

  1. caffeineBundle.loadingCache(CacheNames.FIRST_CACHE, cacheLoader);

Sample Configuration

  1. cacheConfig:
  2. metricsPrefix: io.dropwizard.reporting
  3. defaultCacheConfig:
  4. metricsEnabled: true
  5. caffeineSpec: ""
  6. cache:
  7. FIRST_CACHE:
  8. metricsEnabled: true
  9. caffeineSpec: maximumSize=500, expireAfterAccess=30s

LICENSE

Copyright 2018 Shubham Sharma shubham.sha12@gmail.com.

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.