Share & grow the worlds knowledge!
We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
Đồng bộ dữ liệu dưới Database với cache(Ehcache)
Em có câu hỏi là: khi mình lưu dữ liệu Api vào cache để khi các lần kế tiếp gọi Api thì lấy luôn dữ liệu từ cacche ra. Nếu trường hợp database có thay đổi thì còn cách nào để đồng bộ dữ liệu database với cache ngoài việc clear cache để gọi lại dữ liệu ạ.
Remain: 5
2 Answers

Nguyen Thai Son
Teacher
Nguyen Thai Son
Teacher
Em có thể viết thông qua Backend, khi DB thay đổi phải qua backend -> update cache luôn. Ví dụ updateAge(Int a) {cache.set(cache, a), db.update(a,a)}
-
0
- Reply

tvd12
Teacher
tvd12
Teacher
Hiện tại anh đang áp dụng 2 cách:
- Đồng bộ dữ liệu sau 1 khoảng thời gian ví dụ 15 giây đồng bộ 1 lần, cách này phù hợp với dữ liệu nhỏ, ít thay đổi, không cần thiết phải quá realtime.
- Đồng bộ dữ liệu thông qua việc liên tục lấy các bản ghi theo lastUpdatedAt, cách này phù hợp với dữ liệu nhiều bản ghi, thường xuyên thay đổi và yêu cầu realtime cao.
Tuy nhiên anh đang thấy em đề cập đến Ehcache, em có thể nói rõ hơn trường hợp của mình không?
-
0
- Reply
Em chọn EHCache vì có một số tính năng mạnh mẽ hơn và cung cấp một số tùy chọn cấu hình phong phú hiện tại thì em đang làm theo ý 1 của anh là cấu hình cache một khoản thời gian nào đó sẽ clear để đồng bộ lại dữ liệu mới.Còn ý 2 của anh em chưa hiểu lắm ạ có phải là khi mình update dữ liệu thì mình cần phải update lastUpdatedAt của cache(cấu hình dưới db) để khi lastUpdatedAt có thay đổi thì sẽ chạy job clear cache đi phải k ạ
–
Thân Nam
1685276781000
- Questions 879
- Answers 1.8K
- Best Answers 102
- Users 365
Related Questions
Recent Activities
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
Top Members
Trending Tags
serialization
wordpress
xss
programming-language
facebook
vietqr
network
room database
restful
map
video call
tcp
webrtc
câu hỏi
excel-object-mapper
vuejs
jquery
đồ án tốt nghiệp
lỗi font
oracle
postman
cron
elasticsearch
di
ioc
format json
get file zip
zip file
resttemplate
design patterns
architecture
scheduled spring boot
datetime
#formatdate
paginaiton
microservices
communication
multi-threading
synchronize
otp message
send mail
ssl email
send email
jsonproperty
join
json to object
scheduled
solution
spring websocket cors
refactor
export compliance
config-css
spring websocket
stream api
webflux
mobile
push-noti
jenkins
repository
replica
jotform
refresh token
access token
maria db
junit-test
gorilla
procedure
filter
exception
null
exception handler
upload
resilence4j
bucket4j
readmoretextview
regex
email
qrcode
list
.net
.net oop
partition
oop
c# .net
executor
threadpool
mq
message queue
app
background
h2 database
gallery
deadlock
transaction
monitoring
main
jsp
servlet
tomcat
node.js
watermark
pdf
excel
profile
properties
image
authentication
plugin
udp
access app
project management
estimation
database migration
migration
crawl data
graduation thesis
utf-8 file
validate date
connection pool
thread pool
concurrent
convert date to number
load balancer
nginx
synchronized
lock
graphql
stress test
test
json file
networking
handy terminal
study
computer science
webassembly
assembly
nan
cookie
session
mail template
mail
cosmos-sdk
push notification
socket server
round robin
jetbrains
validate
btree
glide
floating point
artificial intelligence
ai
private_key
duration
hyperloglog
gateway
dns
exception handle
transfer
deploy contract
uniswap
s3
web
ezymq-kafka
ezyredis
soap
transfer git
mongo
integration-test
branch
boot-nodes
springwebflux mysql
index
lưu trữ
dữ liệu lớn
spring-boot-test
macos
apache poi
guide
keycloak
queue
multiple tenant
spring security
extensions
pancakeswap
structure trong spring boot
postgresql
totp
n
cloud reliability
python
golang
bash script
messaging
reactive
roadmap
anti-flooding
cosmos
jvm
abstract class
interface
log4j
non-blocking io
career path
singleton
web3 client
zookeeper
soft delete
centos
ansible
binding
tracking location
socket
optimize
resource
eclip
naming convention
naming
game-room
game-server
log4j-core
jsp & servlet
java core
system environment variables
load-balancing
pgpool
datasource
spring data jpa
schedule
thread
rest
grapql
asyncawait
multithread
math
vector
hibernateconfig
javaw
sjis
shift jis
stream
blog
java spring
nodejs
hibernate
ipfs
issue
build
bundle
vue cli
vue
webpack
fulltextsearch
view
sql
css
html
dex
decentralized exchange
ethereum login
javascript
keep promise
https
nft game
login
thymeleaf
erc721
contract
erc20
web3
smart contract
ropssten
ropsten
metamask
windows 11
bitcoin
eth
ethereum
flutter
isolate
backend nestjs
java web
springsecurity
machine learning
backend
spring aop
winforms
deep learning
model
spring redis
request
pre
nio
io
batch
unit test
slack
log
indexing
sql server
devops
cors
big project
work
frontend
api
cache
draw.io
content-disposition
reactjs download
datastructure
javacore
distraction programing
callback
async
promise
threadjava
unity
orm
rust
pointer
panic
merge
commit
.net core
js
kerberos
security
go
netcore
sosanh
rabbitmq
grpc
ezyhttp
python unicode
front-end
fe
docker
buffered
server
exyfox
career
spring-jpa
jpa
du học
job
bean
spring
reactjs
fullstack
c#
kotlin
sse
websocket
mysql
springboot
rxjava
future
push message android
recyclerview
android
cast
intellij
maven
netty
multithreading
msgpack
json
design-pattern
library
spring boot
redis
hazelcast
atomicboolean
volatile
storage
it
git
caching
chat
game
nft
blockchain
freetank
game-box
jwt
microservice
search
kafka
get
upload file
download
http
opensource
cloud
languague
programming
database
pagination
editor
stackask
question
ezyfox-boot
ezyfox-server
ezyfox
phỏng vấn
java
ezyfoxserver