Last active
April 13, 2025 12:55
-
-
Save ArtDu/d6e1a927a1841e9877777844d14eecc1 to your computer and use it in GitHub Desktop.
Diff patch as addition to vk internal practice 2 (spring redis minimal app)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/pom.xml b/pom.xml | |
| index 674664b..975111a 100644 | |
| --- a/pom.xml | |
| +++ b/pom.xml | |
| @@ -14,5 +14,20 @@ | |
| <version>3.8.1</version> | |
| <scope>test</scope> | |
| </dependency> | |
| + <dependency> | |
| + <groupId>org.springframework.boot</groupId> | |
| + <artifactId>spring-boot-starter</artifactId> | |
| + <version>3.2.12</version> | |
| + </dependency> | |
| + <dependency> | |
| + <groupId>org.springframework.boot</groupId> | |
| + <artifactId>spring-boot-starter-data-redis</artifactId> | |
| + <version>3.2.12</version> | |
| + </dependency> | |
| +<!-- <dependency>--> | |
| +<!-- <groupId>io.tarantool</groupId>--> | |
| +<!-- <artifactId>tarantool-spring-data-32</artifactId>--> | |
| +<!-- <version>1.2.1</version>--> | |
| +<!-- </dependency>--> | |
| </dependencies> | |
| </project> | |
| diff --git a/src/main/java/com/example/App.java b/src/main/java/com/example/App.java | |
| index b6bcb1d..0bfdc90 100644 | |
| --- a/src/main/java/com/example/App.java | |
| +++ b/src/main/java/com/example/App.java | |
| @@ -1,13 +1,21 @@ | |
| package com.example; | |
| -/** | |
| - * Hello world! | |
| - * | |
| - */ | |
| -public class App | |
| -{ | |
| - public static void main( String[] args ) | |
| - { | |
| - System.out.println( "Hello World!" ); | |
| +//import io.tarantool.spring.data32.repository.config.EnableTarantoolRepositories; | |
| +import org.springframework.boot.SpringApplication; | |
| +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| +import org.springframework.context.ApplicationContext; | |
| +import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | |
| + | |
| +@SpringBootApplication | |
| +//@EnableTarantoolRepositories | |
| +@EnableRedisRepositories | |
| +public class App { | |
| + public static void main(String[] args) { | |
| + App.bootstrap(args); | |
| + } | |
| + | |
| + public static ApplicationContext bootstrap(String[] args) { | |
| + return SpringApplication.run(App.class, args); | |
| } | |
| } | |
| + | |
| diff --git a/src/main/java/com/example/Person.java b/src/main/java/com/example/Person.java | |
| new file mode 100644 | |
| index 0000000..645b410 | |
| --- /dev/null | |
| +++ b/src/main/java/com/example/Person.java | |
| @@ -0,0 +1,45 @@ | |
| +package com.example; | |
| + | |
| +//import com.fasterxml.jackson.annotation.JsonFormat; | |
| +//import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |
| +import org.springframework.data.annotation.Id; | |
| +import org.springframework.data.keyvalue.annotation.KeySpace; | |
| +import org.springframework.data.redis.core.RedisHash; | |
| +import org.springframework.data.redis.core.index.Indexed; | |
| + | |
| +import java.time.Instant; | |
| +import java.util.Map; | |
| + | |
| +//@JsonFormat(shape = JsonFormat.Shape.ARRAY) | |
| +//@JsonIgnoreProperties(ignoreUnknown = true) // for example bucket_id | |
| +@KeySpace("person") | |
| +@RedisHash("person") | |
| +public class Person { | |
| + @Id | |
| + public Integer id; | |
| + @Indexed | |
| + public String name; | |
| + public Instant createdAt; | |
| + public Map metadata; | |
| + | |
| + public Person(Integer id, String name, Instant createdAt, Map metadata) { | |
| + this.id = id; | |
| + this.name = name; | |
| + this.createdAt = createdAt; | |
| + this.metadata = metadata; | |
| + } | |
| + | |
| + public Person() { | |
| + } | |
| + | |
| + @Override | |
| + public String toString() { | |
| + return "Person{" + | |
| + "id=" + id + | |
| + ", name='" + name + '\'' + | |
| + ", createdAt=" + createdAt + | |
| + ", metadata=" + metadata + | |
| + '}'; | |
| + } | |
| +} | |
| + | |
| diff --git a/src/main/java/com/example/PersonRepository.java b/src/main/java/com/example/PersonRepository.java | |
| new file mode 100644 | |
| index 0000000..de98db1 | |
| --- /dev/null | |
| +++ b/src/main/java/com/example/PersonRepository.java | |
| @@ -0,0 +1,10 @@ | |
| +package com.example; | |
| + | |
| +import org.springframework.data.repository.CrudRepository; | |
| + | |
| +import java.util.List; | |
| + | |
| +public interface PersonRepository extends CrudRepository<Person, Integer> { | |
| + List<Person> findByName(String name); | |
| +} | |
| + | |
| diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml | |
| new file mode 100644 | |
| index 0000000..a1a1b78 | |
| --- /dev/null | |
| +++ b/src/main/resources/application.yaml | |
| @@ -0,0 +1,9 @@ | |
| +spring: | |
| + data: | |
| + redis: | |
| + host: localhost | |
| + port: 6379 | |
| + tarantool: | |
| + host: localhost | |
| + port: 3301 | |
| + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment