← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Implement a simplified in-memory database with TTL and backup/restore functionality.
Level 1 - Basic Operations:
setData(key, field, value) - Set field-value pair for keygetData(key, field) - Get value, return "" if not existsdeleteData(key, field) - Delete field, return true if existedLevel 2 - Scan Operation:
scanData(key) - Return all "field(value)" pairs, sorted alphabeticallyLevel 3 - TTL (Time-To-Live):
setDataWithTTL(key, field, value, timestamp, ttl) - Set with expiration at timestamp + ttlLevel 4 - Backup and Restore:
backup(timestamp) - Save database state, return count of non-empty recordsrestore(timestamp, backupTimestamp) - Restore from backup, recalculate TTLs based on remaining time