TCache Synchronization

This chapter describes Multi Domain Invalidation and Multi Node Invalidation for TCache synchronization.

1. Overview

When data in a database to which TCache applies is modified, synchronization between TCache data and database table data is required. When updating and deleting data for which TCache is used, an application must perform invalidation.

When directly accessing a database, perform invalidation by using the following command. Note that the following command deletes all cache objects.

pfmtcacheadmin –i [CacheName]

The following shows the TCache synchronization process.

figure5 1
TCache Synchronization

For synchronization of multiple nodes, perform invalidation for each node by using Tmax server named TPFMAGENT. For more information, refer to Multi Domain Invalidation and Multi Node Invalidation (COUSIN).

2. Multi Domain Invalidation

Used in an environment where domain gateway can be set to enable tpacall between nodes. The workflow is the same as in TCache Synchronization. For more information, refer to relevant Tmax guides.

  • Tmax server settings (Node1)

    ###############################################################
    #                                                             #
    #         Sample Configuration File for Tmax System           #
    #         =========================================           #
    #                                                             #
    #     Copyright(c) 2004 TmaxSoft Inc. All rights reserved     #
    #                                                             #
    ###############################################################
    
    
    *DOMAIN
    tmax1           SHMKEY =79000, MINCLH=1, MAXCLH=3,
                    TPORTNO=9999, BLOCKTIME=30
    
    *NODE
    fw2test         TMAXDIR = "/home/pfmO0tm4/proframe4.0/package/tmax",
                    APPDIR  = "/home/pfmO0tm4/proframe4.0/package/tmax/appbin",
                    PATHDIR = "/home/pfmO0tm4/proframe4.0/package/tmax/path",
                    TLOGDIR = "/home/pfmO0tm4/proframe4.0/package/tmax/log/tlog",
                    ULOGDIR = "/home/pfmO0tm4/proframe4.0/package/tmax/log/ulog",
                    SLOGDIR = "/home/pfmO0tm4/proframe4.0/package/tmax/log/slog"
    
    *SVRGROUP
    NFRGRP01        NODENAME = "fw2test"
    
    *SERVER
    #######  TCache Domain SERVER######
    TPFMAGENT       SVGNAME = NFRGRP01
    
    #### TCache alias name ####
    TCACHEFR02      SVGNAME = NFRGRP01, MIN=1, MAX=5, TARGET = TPFMAGENT,
                    CLOPT = "-r -l -x SPFMAGENT:SPFMAGENT02 -o $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"
    
    *SERVICE
    ##### TCache Service ####
    SPFMAGENT       SVRNAME = TPFMAGENT,   SVCTIME=30
    SPFMAGENT02     SVRNAME = TCACHEFR02
    SPFMAGENT01     SVRNAME = TGW02
    # Match SPFMAGENT|2(SPFMAGENT01, SPFMAGENT02) of TCache Config.
    # For invalidation, SPFMAGENT02 is called in local, and SPFMAGENT01 is called in remote.
    # For more information, refer to relevant Tmax guides.
    
    ##### TCache Gateway ####
    *GATEWAY
    TGW02           NODENAME = fw2test, GWTYPE=TMAXNONTX, PORTNO=9302,
                    RGWADDR = "192.168.1.51", RGWPORTNO=9301, RESTART=Y,
                    MAXRSTART=128, CLOPT="-i", CPC=8
  • TCache environment settings (Node1)

    # the configuration file of TCACHE
    
    SHMKEY=0x70005        # the key of shared memory
    IPCPERM=0777          # permission of the shared memory
    SIZE_LOCAL=1024       # L1 cache size in kilobytes
    LIB_PTHREAD=libpthread.so   # the pthread library file name
    
    INVALIDATE_TYPE=1     # Invalidation type 0:multi-node 1:multi-domain
    # INVALIDATE_TYPE: 1 means that a domain gateway is used.
    
    AGENT_SVC=SPFMAGENT|2 # multi-node sync. svc SPFMAGENT|2 = SPFMAGENT01, SPFMAGENT02
    # AGENT_SVC: When there are 2 nodes, set to SPFMAGENT|2. SPFMAGENT01 and SPFMAGENT02 are tpacalled.
    
    # cache for PFM_SVC
    CACHE_NAME=PFM_SVC
    SIZE_MEM=65536      # the total cache memory size in kilobytes
    SIZE_HASH=1024      # the number of hash key (MAX=65536)
    SIZE_KEY=30         # the number of digits of the index column
    SIZE_REC=2048       # the size of a single record in bytes
    INV_TIMEOUT=10      # invalidation timeout in sec
    .
    .
    .
  • Tmax server settings (Node2)

    ###############################################################
    #                                                             #
    #         Sample Configuration File for Tmax System           #
    #         =========================================           #
    #                                                             #
    #     Copyright(c) 2004 TmaxSoft Inc. All rights reserved     #
    #                                                             #
    ###############################################################
    
    
    *DOMAIN
    tmax1           SHMKEY =78898, MINCLH=1, MAXCLH=3,
                    TPORTNO=9030, BLOCKTIME=30
    
    *NODE
    tmaxh6          TMAXDIR = "/data5/proframe4/pfmO1tm4/package/tmax",
                    APPDIR  = "/data5/proframe4/pfmO1tm4/package/tmax/appbin",
                    PATHDIR = "/data5/proframe4/pfmO1tm4/package/tmax/path",
                    TLOGDIR = "/data5/proframe4/pfmO1tm4/logging/tlog",
                    ULOGDIR = "/data5/proframe4/pfmO1tm4/logging/ulog",
                    SLOGDIR = "/data5/proframe4/pfmO1tm4/logging/slog"
    
    *SVRGROUP
    NFRGRP02        NODENAME = "tmaxh6"
    
    *SERVER
    #######  TCache Domain SERVER######
    TPFMAGENT       SVGNAME = NFRGRP02
    
    #### TCache alias name ####
    TCACHEFR01      SVGNAME = NFRGRP02, MIN=1, MAX=5, TARGET = TPFMAGENT,
                    CLOPT = "-r -l -x SPFMAGENT:SPFMAGENT01 -o
                    $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"
    
    *SERVICE
    ##### TCache Service ####
    SPFMAGENT       SVRNAME = TPFMAGENT,   SVCTIME=30
    SPFMAGENT01     SVRNAME = TCACHEFR01
    SPFMAGENT02     SVRNAME = TGW01
    # Match SPFMAGENT|2(SPFMAGENT01, SPFMAGENT02) of TCache Config.
    # For invalidation, SPFMAGENT02 is called in local, and SPFMAGENT01 is called in remote.
    # For more information, refer to relevant Tmax guides.
    
    ##### TCache Gateway ####
    *GATEWAY
    TGW01           NODENAME = tmaxh6, GWTYPE=TMAXNONTX, PORTNO=9301,
                    RGWADDR = "192.168.32.86", RGWPORTNO=9302, RESTART=Y,
                    MAXRSTART=128, CLOPT="-i", CPC=8
  • TCache environment settings (Node2)

    # the configuration file of TCACHE
    
    SHMKEY=0x78016      # the key of shared memory
    IPCPERM=0777        # permission of the shared memory
    SIZE_LOCAL=1024     # L1 cache size in kilobytes
    LIB_PTHREAD=libpthread.so   # the pthread library file name
    INVALIDATE_TYPE=1     # Invalidation type 0:multi-node 1:multi-domain
    # INVALIDATE_TYPE: 1 means that a domain gateway is used.
    AGENT_SVC=SPFMAGENT|2 # multi-node sync. svc SPFMAGENT|2 = SPFMAGENT01, SPFMAGENT02)
    # AGENT_SVC: When there are 2 nodes, set to SPFMAGENT|2. SPFMAGENT01 and SPFMAGENT02 are tpacalled.
    # cache for PFM_SVC
    CACHE_NAME=PFM_SVC
    SIZE_MEM=1024       # the total cache memory size in kilobytes
    SIZE_HASH=1024      # the number of hash key (MAX=65536)
    SIZE_KEY=30         # the number of digits of the index column
    SIZE_REC=1024       # the size of a single record in bytes
    INV_TIMEOUT=10      # invalidation timeout in sec
    .
    .
    .

3. Multi Node Invalidation (COUSIN)

Used in an environment where domain gateway cannot be set. It sets targets to be called by a node in Tmax configuration file, gets tpgetsvglist, and tpacalls the server to be invalidated with tpacallsvg at each node. The workflow is the same as in TCache Synchronization. For more information, refer to relevant Tmax guides.

  • Tmax server settings (both Node1 and Node2)

    ################################################################################
    # DOMAIN SECTION                                                               #
    ################################################################################
    *DOMAIN
    
    SHPDOM05        SHMKEY             = 97990,
                    TPORTNO            = 8890,
                    MAXUSER            = 3000,
                    MINCLH             = 1,
                    MAXCLH             = 2,
                    RACPORT            = 9493,
                    BLOCKTIME          = 1800,
                    MAXSVR             = 2500,
                    MAXSPR             = 6500,
                    MAXSVC             = 20000,
                    MAXSACALL          = 1024,
                    MAXCACALL          = 1024,
                    MAXSVG             = 100,
                    MAXTOTALSVG        = 600,
                    MAXGW              = 1024,
                    MAXCPC             = 400,
                    MAXCOUSIN          = 60,
                    MAXCOUSINSVG       = 120,
                    GWCHKINT           = 30,
                    GWCONNECT_TIMEOUT  = 30,
                    NCLHCHKTIME        = 180,
                    NLIVEINQ           = 30,
                    IPCPERM            = 0664,
                    MAXNODE            = 4
    
    ################################################################################
    # NODE SECTION                                                                 #
    ################################################################################
    *NODE
    BCS01           HOSTNAME = "tmaxi4",
                    TMAXDIR  = "/data2/pfmO0tm4/proframe4.0/package/tmax",
                    APPDIR   = "/data2/pfmO0tm4/proframe4.0/package/tmax/appbin"
    
    BCS02           HOSTNAME = "tmaxi7",
                    TMAXDIR  = "/data2/pfmO1tm4/proframe4.0/package/tmax",
                    APPDIR   = "/data2/pfmO1tm4/proframe4.0/package/tmax/appbin"
    
    ################################################################################
    # Server Group SECTION                                                         #
    ################################################################################
    *SVRGROUP
    
    OPFMGRP11       NODENAME = "BCS01"
    OPFMGRP21       NODENAME = "BCS02"
    
    OPFMGRP31       NODENAME = "BCS01", COUSIN = "OPFMGRP32", LOAD = 0
    OPFMGRP32       NODENAME = "BCS02", LOAD = 0
    
    ################################################################################
    # SERVER SECTION                                                               #
    ################################################################################
    *SERVER
    # TCache Multi Node ..
    TPFMAGENT       SVGNAME = OPFMGRP31, MIN = 1, MAX = 1,
                    CLOPT="-o $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log -e $(SVR)_$(CYEAR)$(CMONTH)$(CDAY).log"
    
    *SERVICE
    
    SPFMAGENT       SVRNAME=TPFMAGENT
    
    # -------------------------------------------------------- #
    # Non Framework ...
    # -------------------------------------------------------- #
  • TCache environment settings (Node1)

    # the configuration file of TCACHE
    
    SHMKEY=0x70099      # the key of shared memory
    IPCPERM=0777        # permission of the shared memory
    SIZE_LOCAL=1024     # L1 cache size in kilobytes
    LIB_PTHREAD=libpthread.so   # the pthread library file name
    INVALIDATE_TYPE=0           # multi-node invalidation type.
    # INVALIDATE_TYPE: 0 means Cousin is used.
    AGENT_SVC = SPFMAGENT # multi-node sync. svc
    # AGENT_SVC: SPFMAGENT server is tpacalled.
    
    # cache for PFM_SVC
    CACHE_NAME=PFM_SVC
    SIZE_MEM=65536      # the total cache memory size in kilobytes
    SIZE_HASH=1024      # the number of hash key (MAX=65536)
    SIZE_KEY=30         # the number of digits of the index column
    SIZE_REC=2048       # the size of a single record in bytes
    INV_TIMEOUT=10      # invalidation timeout in sec
    .
    .
    .
  • TCache environment settings (Node2)

    # the configuration file of TCACHE
    
    SHMKEY=0x70999      # the key of shared memory
    IPCPERM=0777        # permission of the shared memory
    SIZE_LOCAL=1024     # L1 cache size in kilobytes
    LIB_PTHREAD=libpthread.so   # the pthread library file name
    INVALIDATE_TYPE=0           # multi-node invalidation type.
    # INVALIDATE_TYPE: 0 means Cousin is used.
    AGENT_SVC = SPFMAGENT # multi-node sync. svc
    # AGENT_SVC: SPFMAGENT server is tpacalled.
    
    # cache for PFM_SVC
    CACHE_NAME=PFM_SVC
    SIZE_MEM=65536      # the total cache memory size in kilobytes
    SIZE_HASH=1024      # the number of hash key (MAX=65536)
    SIZE_KEY=30         # the number of digits of the index column
    SIZE_REC=2048       # the size of a single record in bytes
    INV_TIMEOUT=10      # invalidation timeout in sec
    .
    .
    .