Wednesday, March 9, 2022

Couchbase vs EPOCH

Couchbase key storage

Firstly, would like to talk about TTL (time to live) for data in couchbase cache.

Let I've 3 APIs:

1. review API
2. approval API
3. booking API

We create a transaction_key for storing the cache data to be used by further layers as per TTL.



Why Different TTLs?

Answer: It makes no sense to store data of all the users for 10000 EPOCH. As we also, want to store data in couchbase efficiently.

There can be 1000 users who lands to review page but don't proceed to booking. Hence, we have max. ttl for user who make booking than, user who just visits review page but don't proceed further.




COUCHBASE VS COUCHBASE SDK

1. Couchbase: is distributed system

2. Couchbase SDK: 
  • are our system on which couchbase sdk is stored
  • time stamp stored in cache SDK = current timestamp in EPOCH + TTL
Only case when couchbase will get expire unexpectedly will be because of time incorrectness in my system.

eg. Suppose in my system on which Couchbase SDK is installed, time is incorrect - by 30min, and TTL for my key in couchbase is 10min in epoch. 
When data will be stored in couchbase cache = - 20min
Hence, it will expire unexpectedly.


Note:
  • EPOCH will be same in all timezones. 
  • Hence, while building the systems like payments, etc. we use time in EPOCH.
  • it is defined as point in time
  • also, it is the count of milli secs from 1970s



No comments:

Post a Comment

Popular Posts

Most Featured Post

GitHub: Squash all commits in PR

  Command Meaning git fetch origin Get the latest origin/master . git reset --soft origin/master Move your branch to match origin/master , b...