Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • RTK Query Documentation39টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Redux Intro
  • Architecture
  • Redux Toolkit
  • Project Setup
  • Folder Structure
  • configureStore
  • Redux Provider
  • createSlice
  • Reducers & Actions
  • Typed Hooks
  • Selectors
  • Devtools
  • RTK Query
  • createApi
  • API Middleware
  • API Tags
  • Fetch List
  • Fetch Detail
  • Mutation — Create
  • Mutation CRUD
  • Cache Invalidation
  • Cache Lifecycle
  • Polling
  • Query Selectors
  • Optimistic Update
  • Cart Slice Full
  • Cart UI
  • Local vs Server
  • Listener Middleware
  • Error Handling
  • Loading States
  • Serializability
  • SSR Prefetch
  • Complete Flow
  • Complete Project
  • Production
  • Common Mistakes
  • Best Practices
  • Interview Q&A
  1. Docs
  2. RTK Query
  3. Tags — providesTags / invalidatesTags
RTK QueryAdvanced

Tags — providesTags / invalidatesTags

Tag system-এর মাধ্যমে cache invalidation — বাংলায়।

5টি অংশবাংলা ভাষায়

Tags RTK Query-এর 'invalidation ভাষা'। কোনো mutation সফল হলে invalidatesTags বলে দেয় কোন cache পুরনো — RTK Query তখন ওইসব query re-fetch করে।

Tag-সহ endpointts
ts
tagTypes: ["Product", "Order"],

getProducts: builder.query<Product[], void>({
  query: () => "products",
  providesTags: (result) =>
    result
      ? [
          ...result.map((p) => ({ type: "Product" as const, id: p.id })),
          { type: "Product", id: "LIST" },
        ]
      : [{ type: "Product", id: "LIST" }],
}),

getProduct: builder.query<Product, string>({
  query: (id) => "products/" + id,
  providesTags: (_result, _err, id) => [{ type: "Product", id }],
}),

deleteProduct: builder.mutation<void, string>({
  query: (id) => ({ url: "products/" + id, method: "DELETE" }),
  // যেকোনো Product tag-সহ query (LIST/detail) সব invalid
  invalidatesTags: [{ type: "Product", id: "LIST" }, "Product"],
}),

updateProduct: builder.mutation<Product, { id: string; body: Partial<Product> }>({
  query: ({ id, body }) => ({ url: "products/" + id, method: "PATCH", body }),
  invalidatesTags: (_result, _err, { id }) => [
    { type: "Product", id },
    { type: "Product", id: "LIST" },
  ],
}),

Tag-ID gist

  • { type: "Product", id: p.id } → নির্দিষ্ট item-এর cache
  • { type: "Product", id: "LIST" } → list-নির্দিষ্ট tag (ধরে নিলেন প্রতিটি GET list এ tag)
  • "Order" (id ছাড়া) → array-শর্টহ্যান্ড — সব Order tag
  • invalidatesTag [LIST + type] → list ও সব detail দুটোই invalid
Tag kn-কেন?

Tags-এর মূল কথা — সার্ভার কী প্রভাব ফেলবে সেটাই index। একটি update list-ও invalidate করে detail cache — নির্ভরশীল সব query একসাথে updated থাকে।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরRTK Query Middleware — Store IntegrationপরেরFetch List — useGetProductsQuery
এই পেজে
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com