Wednesday, 14 December 2016

Rough Draft , Notes

Should we use foreign keys?
 Referential integrity
Performance hit

But the performance hit is only when there are a lot of foregin keys. Because for each row inserted,updated,deleted other tables would also be checked
However, foregin keys helps in optimizing queries and increase reading speed
By default indexes aren't created on foreign keys.
Stackoverflow Link

Jackson Json: How to prevent field serialization?
@JsonIgnore or mark the field as transient

Jacson Json vs Gson
Jackson seems to be winning the race. It has a lot of benefits over Gson and performance is also better.
Spring has default support of jackson.

What's the use of identityhashmap?
It's use is rare, it's used when objects are to be compared via reference equality == and not equals method. Thus, it kinds of break map equals contract ,

 Pipelining can give a big performance boost
Pipelining is used to save RTT(Round trip time), pipelining is nothing but a series of commands sent as one
Redis provides transactions to execute a series of commands
Write MULTI to start, now all the commands will be put in queue, enter EXEC to execute all or DISCARD to discard all. In case something went wrong in between rest will be executed. NO ROLLBACK. Redis supports NO ROLLBACK

Redis scripts are transactional by definition, in future transactions might be deprecated and only scripts will be used.

Redis Memory setting
in redis.conf: maxmemory 100mb, setting it to 0 means no limit, when limit has reached there can be several different eviction policies, noeviction, lru, volatile-lru, etc
Redis doesn't uses true lru,  only apprroximation, a set of keys, to save memory, however setting of sample size can be changed

Redis Cluster
In redis cluster, single db is available, operations involving multiple keys might not be avialable
supports upto 1000 nodes

Read: Redis in Action

Seven Databases in seven weeks
Seven Languages in seven weeks
Seven Web Frameworks in seven weeks

Java SE8 for really impatient