Skip to content

Latest commit

 

History

History
114 lines (89 loc) · 3 KB

File metadata and controls

114 lines (89 loc) · 3 KB

evcache-client-spring-boot-starter

This project provides Netflix EVCache integrations for Spring Boot. See on spring-boot-sample

  1. Dependency Management

repositories {
    jcenter() (1)
}

dependencies {
    compile 'com.github.aafwu00:evcache-client-spring-boot-starter:x.y.z' (2)
}
  1. add jcenter() repository

  2. add dependency

    1. Write java code

@SpringBootApplication
@EnableCaching # (1)
public class Application {
    public static void main(final String[] args) {
        new SpringApplicationBuilder(Application.class).run(args);
    }
}

@Repository
public class TodoRepository {
    @Cacheable(cacheNames = "todos", key = "'findAll'") # (2)
    public List<Todo> findAll() {
        return ...;
    }
}
  1. see on https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/integration.html#cache

  2. cacheNames is sames as evcache.clusters[].appName + . + evcache.clusters[].keyPrefix, when evcache.clusters[].name is blank

    1. Write application.yml code, See on Sample

evcache:
  clusters:
    todos:             # (1)
      appName: EVCACHE # (2)
      keyPrefix: todos # (3)
      exception-throwing-enabled: false

EVCACHE-NODES: shard1=localhost:11211,localhost:11212;shard2=localhost:11213,localhost:11214 # (4)
  1. Cache Name(same as @Cacheable cacheNames)

  2. EVCache Cluster App Name

  3. EVCache Cache Prefix

  4. #{evcache.clusters.todos.appName} + -NODES means memcached server address, see on : https://github.com/Netflix/EVCache/wiki/Sample-EVCache-Deployment#step-4-create-a-cache-deployment-descriptor

Important
spring.cache.type value is exists, evcache will be ignored
Table 1. Table EVCache Properties
Name Default Description

evcache.enabled

true

evcache.allowNullValues

true

Whether to allow cache for null values

evcache.deleteWhitespaceKey

false

Delete whitespace key. Careful, Both of 'ab' and 'a b' are same key

evcache.clusters.[cacheName]

Name of the Cache, @Cacheable cacheName

evcache.clusters.[cacheName].striped

0

The minimum number of stripes (locks) required. default is zero, if zero then striped will be cpu * 4

evcache.clusters.[cacheName].appName

Name of the EVCache App clusters, Recommend Upper Case

evcache.clusters.[cacheName].keyPrefix

Cache Prefix Key, Don’t contain colon(:) character

evcache.clusters.[cacheName].timeToLive

900s

Default Time To Live(TTL), Seconds

evcache.clusters.[cacheName].retryEnabled

true

Retry across Server Group for cache misses and exceptions

evcache.clusters.[cacheName].exceptionThrowingEnabled

false

Exceptions are not propagated and null values are returned

evcache.metrics.enabled

true

Spring Boot Metrics for EVCache