Files
TelegaBot/src/main/java/ru/cathub/telegabot/service/BookCacheService.java
T
2025-02-07 16:07:21 +03:00

41 lines
1.4 KiB
Java

package ru.cathub.telegabot.service;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import ru.cathub.telegabot.model.BookCreationCache;
import ru.cathub.telegabot.model.BookEditStateCache;
import ru.cathub.telegabot.model.BookListCache;
import static ru.cathub.telegabot.utils.Constants.*;
public interface BookCacheService {
@Cacheable(value = BOOK_CACHE_NAME, key = "#userId")
BookCreationCache getCache(Long userId);
@CachePut(value = BOOK_CACHE_NAME, key = "#userId")
BookCreationCache updateCache(Long userId, BookCreationCache cache);
@CacheEvict(value = BOOK_CACHE_NAME, key = "#userId")
void clearCache(Long userId);
@Cacheable(value = BOOK_CACHE_LIST, key = "#userId")
BookListCache getBookListState(Long userId);
@CachePut(value = BOOK_CACHE_LIST, key = "#userId")
BookListCache updateBookListState(Long userId, BookListCache state);
@Cacheable(value = BOOK_CACHE_EDIT, key = "#userId")
BookEditStateCache getBookEditCache(Long userId);
@CachePut(value = BOOK_CACHE_EDIT, key = "#userId")
BookEditStateCache updateBookEditCache(Long userId, BookEditStateCache cache);
@CacheEvict(value = BOOK_CACHE_EDIT, key = "#userId")
void clearBookEditCache(Long userId);
@CacheEvict(value = BOOK_CACHE_LIST, key = "#userId")
void clearBookListCache(Long userId);
}