Skip to content

Commit

Permalink
fix demos
Browse files Browse the repository at this point in the history
  • Loading branch information
areyouok committed Oct 11, 2023
1 parent f601b73 commit 4ebdca4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
15 changes: 9 additions & 6 deletions samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,20 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
<!--<version>1.7.36</version>-->
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.36</version>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<!--<version>1.2.11</version>-->
<version>1.4.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.11</version>
<artifactId>logback-core</artifactId>
<!--<version>1.2.11</version>-->
<version>1.4.11</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import com.alicp.jetcache.Cache;
import com.alicp.jetcache.CacheManager;
import com.alicp.jetcache.template.QuickConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.time.Duration;

/**
* @author huangli
*/
@Component
public class MyServiceImpl implements MyService {
public class MyServiceImpl implements MyService, InitializingBean {

@Autowired
private UserService userService;
Expand All @@ -26,8 +26,8 @@ public class MyServiceImpl implements MyService {

private Cache<String, String> orderCache;

@PostConstruct
public void init() {
@Override
public void afterPropertiesSet() {
QuickConfig quickConfig = QuickConfig.newBuilder("orderCache").expire(Duration.ofSeconds(100)).build();
orderCache = cacheManager.getOrCreateCache(quickConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
@SpringBootApplication
public class CacheReader {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(CacheUpdater.class);
ConfigurableApplicationContext context = SpringApplication.run(CacheReader.class);
CacheManager cm = context.getBean(CacheManager.class);
QuickConfig qc = QuickConfig.newBuilder("spring-boot-sync-test")
.cacheType(CacheType.BOTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import com.alicp.jetcache.Cache;
import com.alicp.jetcache.CacheManager;
import com.alicp.jetcache.template.QuickConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.time.Duration;

/**
* @author huangli
*/
@Component
public class MyServiceImpl implements MyService {
public class MyServiceImpl implements MyService, InitializingBean {
@Autowired
private UserService userService;

Expand All @@ -25,8 +25,8 @@ public class MyServiceImpl implements MyService {

private Cache<String, String> orderCache;

@PostConstruct
public void init() {
@Override
public void afterPropertiesSet() {
QuickConfig quickConfig = QuickConfig.newBuilder("orderCache").expire(Duration.ofSeconds(100)).build();
orderCache = cacheManager.getOrCreateCache(quickConfig);
}
Expand Down

0 comments on commit 4ebdca4

Please sign in to comment.