Skip to content

Instantly share code, notes, and snippets.

View Denuwanhh's full-sized avatar
🎯
Focusing

Denuwan Himanga Hettiarachchi Denuwanhh

🎯
Focusing
View GitHub Profile
package com.booking.service;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
@Service
public class BookingService {
@Cacheable("echoCacheWithParam")
public String getServiceDetails(String level) {
package com.booking.contraller;
import com.booking.model.Booking;
import com.booking.service.BookingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("booking")
public class BookingController {
package com.booking;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
@EnableCaching
package com.booking;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@Configuration
spring.redis.host=xxx.xxx.xxx.xxx
spring.redis.port=xx
spring.redis.password=xxxxxxxx
spring.cache.redis.time-to-live=10000
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.pivotal.cfenv</groupId>
<artifactId>java-cfenv-boot</artifactId>
<version>2.4.0</version>
apiVersion: v1
kind: Service
metadata:
name: redis-service
labels:
app: redis
spec:
selector:
app: redis
ports:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
spec:
serviceName: redis
replicas: 3
selector:
matchLabels:
app: redis
apiVersion: v1
kind: PersistentVolume
metadata:
name: local-pv1
spec:
storageClassName: local-storage
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: Delete