-
1
what is redis and how did you implement it?Times asked 1Official solution
SimpleRedis fridge pe sticky note hai — poori kitchen (database) kholne ki zarurat nahi.
Redis in-memory key-value store hai. Data RAM mein rehta hai, isliye disk wale SQLite/Postgres se kai guna tez.
MAD2 mein Redis do kaam karta hai:
1) Cache — same venue/show/dashboard JSON baar-baar DB se mat nikaalo.
2) Celery message broker — Flask task queue mein daalta hai, worker uthata hai.Source of truth database hi hai. Redis band ho to cache miss ho jaata hai aur Celery queue ruk sakti hai. Crash pe cache gayab ho sakta hai — isliye important data sirf Redis mein mat rakho.
Example
import redis r = redis.Redis(host='localhost', port=6379, db=0) r.set('venues', json.dumps(data), ex=30) print(r.get('venues'))Project example: GET /api/venues pehle Redis dekho. Miss pe SQLAlchemy query, phir SET with timeout. Celery worker Redis list se daily reminder uthata hai.
Viva tipCache ke liye db=1, broker ke liye db=0 rakhna smart hai taaki keys mix na hon. Viva mein
redis-cli ping→ PONG dikhana strong hai.Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
2
what are lifecycle hooks? explain a few of themTimes asked 2Official solution
SimpleLifecycle = component ki zindagi ke stages. API call tab jab DOM ready ho — mounted.
created: instance bani,
thisdata, DOM nahi. mounted/onMounted: page pe aa gaya — fetch, Chart.js, setInterval.
updated: data change ke baad. unmounted: cleanup (clearInterval) warna memory leak.Dashboards onMounted isliye: canvas/API tab valid. created mein $el nahi.
Composition: onMounted(() => {}) setup ke andar.
Example
export default { async mounted() { const r = await fetch('/api/venues') this.venues = await r.json() } }Project example: Venues.vue mounted fetch list. Clock component unmounted pe interval clear.
Viva tipcreated: data setup, DOM nahi. mounted/onMounted: $el mil gaya — fetch yahi. Dashboards isliye onMounted use karti hain.
Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
3
explain celery w.r.t your codeTimes asked 2Official solution
SimpleCode explain formula: input kya aaya → auth/validation → DB change → response/UI.
Viva tipFunction signature + 3-4 important lines + edge case.
Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
4
how are you doing RBAC?Times asked 2Official solution
SimpleRBAC = Role Based Access Control. Roles (admin/user) se permissions milti hain, har user pe alag list nahi.
Example
if current_user.role != 'admin': flash('Not allowed') return redirect(url_for('user.home'))Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
5
what are props in vue?Times asked 1Official solution
SimpleVue.js frontend framework — reactive UI components. MAD2 mein common, MAD1 optional.
Component: reusable UI (Navbar.vue) + data + template.
Props: parent → child data. Child → parent: $emit('update', val).
Slots: parent child ke andar extra HTML daal sakta hai.
Lifecycle: created (data setup), mounted (DOM ready — API call), updated, unmounted.
v-model two-way bind. Vue Router SPA routes (routes.js). Vuex/Pinia global state; mutations sync change, actions async.
Standalone component: khud ke saath compile, parent register kam.Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
6
show a component and explain fetch request and the lifecycle hook usedTimes asked 1Official solution
SimpleLifecycle = component ki zindagi ke stages. API call tab jab DOM ready ho — mounted.
created: instance bani,
thisdata, DOM nahi. mounted/onMounted: page pe aa gaya — fetch, Chart.js, setInterval.
updated: data change ke baad. unmounted: cleanup (clearInterval) warna memory leak.Dashboards onMounted isliye: canvas/API tab valid. created mein $el nahi.
Composition: onMounted(() => {}) setup ke andar.
Example
export default { async mounted() { const r = await fetch('/api/venues') this.venues = await r.json() } }Project example: Venues.vue mounted fetch list. Clock component unmounted pe interval clear.
Viva tipcreated: data setup, DOM nahi. mounted/onMounted: $el mil gaya — fetch yahi. Dashboards isliye onMounted use karti hain.
Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
7
diff between caching and memoizationTimes asked 1Official solution
SimpleMemoize args-aware. cached view/URL. Prefixes differ.
Same Redis. Different key recipe.
Redis in-memory key-value store hai — fridge pe sticky note, poori kitchen (SQL database) har baar mat kholo.
MAD2 mein Redis do kaam: (1) cache — same venues/shows/dashboard JSON baar-baar DB se nahi (2) Celery broker — Flask task queue mein daalta hai, worker uthata hai.
Flow: cache.get(key) → hit pe return, miss pe SQLAlchemy + SET with timeout. Admin write ke baad cache.delete, warna stale list.
Source of truth database hi hai. Redis crash/band = cache miss (app chalni chahiye) + queue ruk sakti hai. Important bookings sirf Redis mein mat rakho.
Alag: Redis ≠ Memcached (Celery broker nahi). Redis ≠ localStorage (woh browser).
redis-cli ping→ PONG viva proof.Project example: Two decorators two files explain.
Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet
-
8
show where you have implemented caching and why we need itTimes asked 1Official solution
SimpleCache = pehli baar hisaab karke copy rakh lo, doosri baar copy dikha do.
Baar-baar same expensive kaam (DB query, counting bookings) mat karo. Result Redis jaise store mein timeout ke saath rakh do.
Cache hit: key mil gayi, DB skip. Cache miss: DB se lao, SET karo, return karo.
Tradeoff: speed vs stale data. Admin naya venue add kare aur cache 50s ka ho to user purani list dekh sakta hai — isliye write pe invalidation zaroori hai.
Browser cache, Flask-Caching, Redis alag layers hain. MAD2 examiner Redis +
@cache.cachedcode dekhta hai.Example
@cache.cached(timeout=50, query_string=True) @app.route('/api/shows') def shows(): return jsonify([s.serialize() for s in Show.query.all()])Project example: Admin dashboard counts / venues list cache. Create/update/delete ke baad
cache.delete('venues').Viva tipprint('DB queried') function ke andar laga ke miss/hit demo karo — hit pe print nahi chalega.
Community answers
No replies yet
No community answers yet
Open My solution to be the first to share yours.
My solution
Not submitted yet