TypeScript-based cache determination method and device, computer equipment and storage medium

By configuring cache parameters and generating cache keys using TypeScript decorators on the target method, the insufficient throughput of the cache management system in high-concurrency scenarios is solved, achieving efficient cache data processing, reducing server load and improving system performance.

CN120994250APending Publication Date: 2025-11-21CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511221627.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-28
Publication Date
2025-11-21

AI Technical Summary

Technical Problem

In fields such as fintech, healthcare, and elderly care, existing technologies struggle to effectively improve the throughput of cache management systems for handling high-concurrency cached data, leading to increased server load and longer response times.

Method used

By using TypeScript decorators to configure cache parameters on target methods, intercepting call instructions to generate cache keys, and reading and processing cache data from a preset repository, a zero-intrusion caching mechanism is achieved, which encrypts, de-identifies, or converts the format of the return value content.

Benefits of technology

It improves the throughput of the cache management system in handling high-concurrency cached data, reduces server pressure, shortens response time, and enhances system efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120994250A_ABST
    Figure CN120994250A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of Internet, and discloses a TypeScript-based cache determination method and device, computer equipment and a storage medium, and the method comprises the steps: configuring cache parameters for a target method through a preset open source programming language TypeScript decorator; intercepting a calling instruction of the target method through an intercepting instruction, and generating a cache key associated with the calling instruction; reading initial cache data corresponding to the cache key from a preset storage library according to the cache parameter, generating a return value, and determining target cache data according to the return value. By means of the mode, the decorator is added to the target method, a complete cache mechanism is introduced, different input scenes are accurately matched according to the cache key corresponding to the calling instruction, and encryption or desensitization or format conversion is automatically completed according to the content of the returned value. The method can be applied to the business fields of financial science and technology, medical health, old-age care and the like, and the throughput capacity of the cache management system for processing high-concurrency cache data is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Internet, and particularly relates to a TypeScript-based cache determination method and device, a computer device and a storage medium. BACKGROUND

[0002] With the rapid development of Internet technology, in modern network application development, frequent access to backend application interfaces to obtain data will increase the server load.

[0003] In the financial technology business field of insurance claims, securities market, payment settlement and other financial technology scenarios, terminal users need to complete page rendering and interaction within milliseconds; at the same time, the peak concurrent volume of transactions can reach tens of thousands per second. Any redundant backend call can amplify the pressure on the backend cluster, lengthen the link time, and thus affect the transaction rate or customer satisfaction. In the medical and health care business field, the front-end application needs to frequently call the back-end interface to obtain the health records, medication plans, nursing records, real-time vital signs data (blood pressure, blood sugar, blood oxygen, etc.) and medical insurance settlement information of the old people. Developers often seek to cache data with lower update frequency to reduce the number of server requests. Therefore, how to improve the throughput capacity of the cache management system in the financial technology, medical and health care business field to process high-concurrency cache data has become a technical problem to be solved. SUMMARY

[0004] The present application provides a TypeScript-based cache determination method and device, a computer device and a storage medium to improve the throughput capacity of the cache management system to process high-concurrency cache data.

[0005] In a first aspect, the present application provides a TypeScript-based cache determination method, which comprises:

[0006] The target method is configured with a cache parameter by a preset open source programming language TypeScript decorator;

[0007] The calling instruction of the target method is intercepted by an interception instruction, and a cache key associated with the calling instruction is generated;

[0008] According to the cache parameter, the initial cache data corresponding to the cache key is read from a preset storage library, a return value is generated, and the target cache data is determined according to the return value.

[0009] In a second aspect, the present application also provides a TypeScript-based cache determination device, which comprises:

[0010] The cache parameter configuration module is configured to configure a cache parameter for a target method by using a preset open source programming language TypeScript decorator.

[0011] The cache key generation module is configured to intercept a calling instruction of the target method by using an interception instruction, and generate a cache key associated with the calling instruction.

[0012] The target cache data determination module is configured to read initial cache data corresponding to the cache key from a preset storage according to the cache parameter, generate a return value, and determine target cache data according to the return value.

[0013] In a third aspect, the present application further provides a computer device, which comprises a memory and a processor; the memory is configured to store a computer program; and the processor is configured to execute the computer program and implement the TypeScript-based cache determination method as described above when executing the computer program.

[0014] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program; and the computer program is configured to enable a processor to implement the TypeScript-based cache determination method as described above when executed by the processor.

[0015] The present application discloses a TypeScript-based cache determination method, device, computer device and storage medium. The TypeScript-based cache determination method comprises configuring a cache parameter for a target method by using a preset open source programming language TypeScript decorator; intercepting a calling instruction of the target method by using an interception instruction, and generating a cache key associated with the calling instruction; reading initial cache data corresponding to the cache key from a preset storage according to the cache parameter, generating a return value, and determining target cache data according to the return value. In this way, the present application introduces a complete cache mechanism by adding a decorator to the target method, accurately matches different input scenarios according to the cache key corresponding to the calling instruction, and automatically completes encryption, desensitization or format conversion according to the return value content. The present application can be applied to business fields such as financial technology, medical health and old-age care, and improves the throughput capacity of the cache management system for processing high-concurrency cache data. BRIEF DESCRIPTION OF DRAWINGS

[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0017] Figure 1is a schematic flowchart of a TypeScript-based cache determination method provided by an embodiment of the present application;

[0018] Figure 2 is a schematic block diagram of a TypeScript-based cache determination apparatus provided by an embodiment of the present application;

[0019] Figure 3 is a structural schematic block diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0020] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0021] The flowchart shown in the drawings is only an example and does not necessarily include all the contents and operations / steps, nor does it necessarily be executed in the order described. For example, some operations / steps can be further decomposed, combined or partially merged, so the actual execution order may be changed according to the actual situation.

[0022] It should be understood that the terms used in the specification of the present application are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the specification and the appended claims of the present application, unless otherwise clear from the context, the singular forms "a", "an" and "the" are intended to include the plural forms.

[0023] It should also be understood that the term "and / or" used in the specification and the appended claims of the present application means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.

[0024] Embodiments of the present application provide a TypeScript-based cache determination method, apparatus, computer device and storage medium. The TypeScript-based cache determination method can be applied to a cache management system, a complete cache mechanism is introduced by adding a decorator on a target method, different input scenarios are accurately matched according to a cache key corresponding to a calling instruction, and encryption, desensitization or format conversion is automatically completed according to a return value content. The present application can be applied to business fields such as financial technology, medical health and old-age care, and improves the throughput capacity of the cache management system for processing high-concurrency cache data.

[0025] Some embodiments of the present application will be described in detail with reference to the drawings. The following embodiments and features of the embodiments described below can be combined with each other without conflict.

[0026] Please refer to Figure 1 , Figure 1 is a schematic flowchart of a TypeScript-based cache determination method provided by an embodiment of the present application. The TypeScript-based cache determination method can be applied to a cache management system, and is used in the business fields of financial technology, medical and health care, and the like, to improve the throughput capacity of the cache management system in processing high-concurrency cache data.

[0027] As Figure 1 shown, the TypeScript-based cache determination method specifically includes steps S10 to S30.

[0028] Step S10, configure cache parameters for a target method through a preset open source programming language TypeScript decorator;

[0029] Specifically, a custom decorator factory function is introduced in a TypeScript (an open source programming language) source code file, the decorator is directly added above the target method that needs to be cached, and cache configuration is completed at one time through the decorator parameters. The decorator is retained by the TypeScript compiler in the compilation stage, and at runtime, the above-mentioned cache parameters are bound to the target method by using the decorator execution context, so as to provide configuration basis for subsequent interception, cache key generation, data reading and updating, and realize zero-intrusion cache capability injection.

[0030] In the financial technology business field, taking the claim settlement scenario as an example, for the target method of "getting case details", which is high-frequency but low-frequency in data change, first, configure cache parameters for it through the preset decorator, specify the cache scope as windowed storage of the current user session, ensure that sensitive information is only available within the current login period, set the cache validity period to 5 minutes according to the regulatory requirements on data timeliness, and prevent expired policy information from misleading risk control decisions. Enable the "hybrid data protection" strategy, encrypt the policy number and ID number fields in the returned object and store them in the local storage, and the remaining public information such as case status and claim settlement progress is still written in the windowed storage in plaintext.

[0031] In the field of medical health and elderly care, the interface method of "getting patient's medical history" is configured using TypeScript decorator @. In the decorator parameters, the cache validity period is set to 30 minutes to balance data timeliness and treatment efficiency; at the same time, the storage is specified as windowed storage to ensure that sensitive medical records are only available within the current browser tab session, and are automatically cleared when the page is closed, which meets the privacy compliance requirements. After the configuration is completed, when the doctor clicks the patient card for the first time in the electronic medical record system, the system will call the backend interface and cache the returned complete medical history data in the windowed storage; within the next 30 minutes, any subsequent operation of viewing the same patient's medical record directly reads from the cache without repeated requests to the backend, which not only reduces the server pressure, but also significantly shortens the page loading time, improves the doctor's diagnosis efficiency and patient experience.

[0032] Step S20, intercept the call instruction of the target method by intercepting the instruction, and generate a cache key associated with the call instruction;

[0033] Specifically, when the target method is called, the proxy function generated by the decorator at runtime first intercepts this call instruction; the proxy function reads the method fully qualified name, parameter list and its serialized value when calling, and uses a hash algorithm to calculate the combination of information into a fixed length string, thereby generating a cache key corresponding to this call uniquely; then, the proxy function passes the cache key to the subsequent cache read-write logic for positioning or creating corresponding cache data in the local storage, realizing precise cache isolation at the call level.

[0034] In the financial technology business field, when the user clicks the "view case details" button on the front end to trigger the call, the interceptor generated by the decorator inside the decorator takes effect immediately. Read the user ID of the currently logged-in user, the case ID in the request parameters, and the batch number of the day to generate a cache key. Hash the key and take the first 16 bytes as the final cache key to prevent key name from leaking sensitive information.

[0035] In the field of medical health and elderly care, when the doctor clicks the "view examination report" button to trigger the target method, the interceptor immediately captures the call instruction, concatenates it into a cache key according to the established rules, and automatically appends the current login doctor's department ID as a namespace prefix, which not only ensures that the reports of the same patient in different departments do not interfere with each other, but also facilitates subsequent precise cache hits.

[0036] Step S30, reading the initial cache data corresponding to the cache key from the preset storage according to the cache parameter, generating a return value, and determining the target cache data according to the return value.

[0037] Specifically, according to the cache key, the corresponding entry in the preset repository is queried; if the entry exists, the initial cache data stored in the entry is read and validity is checked according to the network validity period and the encryption mark in the cache parameter; if the network validity period has not expired and the signature / encryption check is passed, it is considered valid, and the data is directly deserialized as a return value; if the entry does not exist or the check fails, the original target method is immediately called to obtain the latest data as a return value, and then the return value is processed into the final target cache data according to the same cache key according to the cache parameter, and is written into the preset repository, ensuring that subsequent calls can be directly reused.

[0038] The application discloses a TypeScript-based cache determination method and device, a computer device and a storage medium. The TypeScript-based cache determination method comprises the following steps: configuring cache parameters for a target method through a preset open source programming language TypeScript decorator; intercepting a calling instruction of the target method through an interception instruction, and generating a cache key associated with the calling instruction; reading initial cache data corresponding to the cache key from a preset repository according to the cache parameters, generating a return value, and determining target cache data according to the return value. In the foregoing manner, the complete cache mechanism is introduced by adding the decorator to the target method, different input scenarios are accurately matched according to the cache key corresponding to the calling instruction, and encryption, desensitization or format conversion are automatically completed according to the return value content. The application can be applied to the business fields of financial technology, medical health and old-age care, and improves the throughput capacity of the cache management system for processing high-concurrency cache data.

[0039] Based on Figure 1 In the embodiment shown in the figure, step S20 comprises:

[0040] The target method name of the target method is extracted, and the interception instruction is determined according to the target method name;

[0041] Each calling parameter in the calling instruction is parsed;

[0042] The calling parameter type and the calling parameter value of each calling parameter are identified through the interception instruction;

[0043] The cache key is generated according to the calling parameter type and the calling parameter value.

[0044] Specifically, the target method name of the target method is extracted by using the TypeScript runtime metadata, and the name is used as the benchmark identifier for generating the interception instruction. When the proxy function intercepts the calling instruction, the parameter list is traversed one by one, and the type and the actual value of each calling parameter are reflected and parsed.

[0045] The interception instruction takes the target method name as a prefix, concatenates the types and values of each parameter into a structured string, and performs a hash operation on the string to finally obtain a cache key that uniquely corresponds to this call.

[0046] In the field of financial technology business, the decorator runtime uses the TypeScript reflection mechanism to extract the target method name being decorated, generates an interception instruction named after the method name, and mounts it to the method call chain. When the user clicks "View Case Details" on the front end to trigger a call, the interceptor parses the three parameters in the call instruction: the policy case number, the user's unique identifier for the current session, and the batch number returned by the server. Concatenate the three according to the financial key name specification, then hash and take the first 16 bytes to finally generate a unique cache key, which is used for subsequent cache hits and data isolation to ensure that data between different cases or different batches for the same user does not interfere with each other.

[0047] Based on Figure 1 In the embodiment, step S30 includes:

[0048] determining whether the initial cache data exists in the preset repository, and generating a determination result;

[0049] In the case where the determination result is that the initial cache data exists in the preset repository, performing validity detection on the initial cache data and the cache parameter;

[0050] In the case where the initial cache data and the cache parameter pass the validity detection, generating the target return value according to the initial cache data and the cache parameter.

[0051] Specifically, the cache key is called to determine whether an entry corresponding to the cache key exists in the preset repository; if the return value is "non-existent", the cache logic is directly skipped and the original method is continued to be executed; if the return value exists, validity detection is entered:

[0052] The creation timestamp saved in the entry is compared with the network validity period in the cache parameter; if the current timestamp minus the creation timestamp is greater than the network validity period, it is determined that the timeout is invalid;

[0053] If the cache parameter contains an encryption mark, the ciphertext in the entry is decrypted using a pre-shared key and the signature is verified; if the decryption fails or the signature does not match, it is determined to be invalid;

[0054] If the entry also contains a data version number field, it is compared with the current configuration version number; if they are inconsistent, it is determined to be invalid.

[0055] In the field of financial technology business, the decorator interceptor first queries the preset repository with a cache key, checks the windowed storage of the user session, and reads the corresponding initial cache data block if a hit is made; then validity detection is performed:

[0056] The current time in the cache header is compared with the network validity period. If the current time has exceeded the network validity period, it is determined that the network validity period is invalid.

[0057] After both detections pass, the encrypted fields (policy number, ID number) are decrypted with the session key, and merged with the plaintext fields (case status, claim progress) to form a complete object, which is packaged into the target return value and directly returned to the front end, significantly reducing the backend load.

[0058] In specific embodiments, in the case where the determination result is that the initial cache data exists in the preset repository, validity detection is performed on the initial cache data and the cache parameters, including:

[0059] Current time information of the initial cache data is obtained;

[0060] The current time information and the cache timestamp parameter are compared to generate a comparison result;

[0061] In the case where the current time information is less than or equal to the cache timestamp parameter, it is determined that the initial cache data and the cache parameters pass the validity detection.

[0062] Specifically, the proxy function first reads the timestamp field attached to the initial cache data from the preset repository. The timestamp field is calculated by "current system time + cache validity period", and the system clock is called to obtain the current time information; the current time information is directly compared with the cache timestamp. If the current time is less than or equal to the cache timestamp, it indicates that the data is still within the validity period, i.e. it is determined that the initial cache data and the cache parameters pass the validity detection, and the subsequent deserialization and return value generation process can continue; otherwise, if the current time is greater than the cache timestamp, it is considered as timeout invalid, and the original target method is triggered to obtain the latest data immediately.

[0063] In the field of medical health and aging business, after reading the initial cache data from the windowed storage, the current time information and the cache validity period saved therein are immediately extracted and compared. If the calculated expiration time (14:45:00) has not arrived, i.e. the current time is less than or equal to the cache validity period, it is determined that the patient's test report cache is still within the validity period, and the decrypted report data is immediately returned as the target result to the doctor's end page rendering, which not only guarantees data timeliness compliance, but also significantly reduces network request delay.

[0064] In the financial technology claim settlement scenario, the decorator interceptor extracts the current time information of the initial cache data from the cache header field and compares it with the cache timestamp parameter in the cache parameter at the millisecond level; if the current browser time (i.e., the current time information) is less than or equal to the cache validity period, it is determined that the cache has not expired, an "effective" comparison result is generated, the initial cache data and the cache parameter pass the validity detection, and the front end can be immediately returned, avoiding the need to call the backend claim settlement service again, ensuring that the data time limit meets the regulatory requirements and reducing system load.

[0065] In specific embodiments, the return value also includes an initial return value, and after determining whether the initial cache data exists in the preset repository and generating a judgment result, the following steps are included:

[0066] If the initial cache data does not exist in the preset repository or the current time information is greater than the cache timestamp parameter, the target method is executed and the initial return value is generated.

[0067] Specifically, when the proxy function detects that the initial cache data corresponding to the cache key does not exist in the preset repository or the current time information is greater than the cache timestamp parameter attached to the cache key, the cache path is immediately abandoned, and the target method is executed with the original call parameters; after the target method is executed, the return result is the initial return value.

[0068] In the financial technology claim settlement scenario, if the interceptor does not find the initial cache data corresponding to the cache key in the windowed storage or detects that the current time has exceeded the current time information in the cache header, the original target method is immediately released and executed, the target method sends a request to the backend claim settlement service, the backend returns the latest case details (including encrypted sensitive fields), and the front-end decorator encrypts the policy number and identity card number with the session key according to the encryption strategy and writes them into the cache along with the plaintext state information.

[0069] In specific embodiments, step S30 in this embodiment includes:

[0070] In the case where the return value is the target return value, the sensitive field set of the initial cache data is extracted and encrypted to generate the target cache data.

[0071] In the case where the return value is the initial return value, the initial cache data is determined as the target cache data.

[0072] Specifically, it is judged whether the return value finally generated in this process is a "target return value" of cache hit or a "initial return value" newly calculated. If it is a target return value of cache hit, the corresponding initial cache data is read out from the preset storage library, the encryption algorithm and key specified in the decorator configuration are used to extract and traverse the predefined sensitive field set (such as policy number, ID number, etc.) therein, and each field is written back after encryption to form encrypted target cache data;

[0073] If the return value is derived from the initial return value newly executed, the encryption process is skipped, and the initial cache data is directly determined as the final target cache data, and is prepared to be written into the preset storage library.

[0074] In the field of financial technology business, when the decorator determines that the return value is a target return value that has been hit (i.e. cache is valid), the sensitive field set (such as policy number, ID number, bank card number) specified by the regulator is identified from the initial cache data, encrypted using the front-end session key, and the encrypted ciphertext replaces the original field value to generate target cache data and return it to the page rendering.

[0075] If the return value is the initial return value newly pulled by the back-end (cache miss or invalid), the encryption step is skipped, and the complete but uncached initial cache data is directly used as the target cache data for immediate display on the front-end, while triggering the subsequent asynchronous cache writing process.

[0076] Based on any of the above embodiments, step S10 includes:

[0077] The namespace identifier of the target method is defined through the TypeScript decorator;

[0078] The data storage location and data valid storage time of the target method are specified through the TypeScript decorator;

[0079] The namespace identifier, data storage location and data valid storage time are determined as the cache parameters.

[0080] Specifically, in the TypeScript source code, the target method is annotated using the decorator; in the compilation stage, the decorator function reads the annotation, extracts the namespace as the namespace identifier, the storage medium as the data storage location, and the cache validity period as the data valid storage time, and encapsulates the three pieces of information into a read-only object, which is injected into the cache context at runtime, thereby forming the complete cache parameters required for subsequent cache reading and writing.

[0081] Please refer to Figure 2 , Figure 2An embodiment of the present application provides a schematic block diagram of a TypeScript-based cache determination device for executing the aforementioned TypeScript-based cache determination method. The TypeScript-based cache determination device can be configured on a server.

[0082] As shown in Figure 2 The TypeScript-based cache determination device 400 comprises the following modules:

[0083] A cache parameter configuration module 410 is configured to configure a cache parameter for a target method by using a preset open-source programming language TypeScript decorator.

[0084] A cache key generation module 420 is configured to intercept a calling instruction of the target method by using an interception instruction, and generate a cache key associated with the calling instruction.

[0085] A target cache data determination module 430 is configured to read initial cache data corresponding to the cache key from a preset storage library according to the cache parameter, generate a return value, and determine target cache data according to the return value.

[0086] Further, the cache key generation module 420 comprises the following modules:

[0087] An interception instruction determination unit is configured to extract a target method name of the target method, and determine the interception instruction according to the target method name.

[0088] A calling parameter analysis unit is configured to analyze each calling parameter in the calling instruction.

[0089] A calling parameter identification unit is configured to identify a calling parameter type and a calling parameter value of each calling parameter by using the interception instruction.

[0090] A cache key generation unit is configured to generate the cache key according to the calling parameter type and the calling parameter value.

[0091] Further, the target cache data determination module 430 comprises the following modules:

[0092] A judgment result generation unit is configured to determine whether the initial cache data exists in the preset storage library, and generate a judgment result.

[0093] An effectiveness detection unit is configured to perform effectiveness detection on the initial cache data and the cache parameter in a case where the judgment result is that the initial cache data exists in the preset storage library.

[0094] The target return value generation unit is configured to generate the target return value according to the initial cache data and the cache parameter when the initial cache data and the cache parameter pass the validity detection.

[0095] Further, the validity detection unit comprises:

[0096] The current time information acquisition subunit is configured to acquire current time information of the initial cache data.

[0097] The comparison result generation subunit is configured to compare the current time information and the cache timestamp parameter to generate a comparison result.

[0098] When the current time information is less than or equal to the cache timestamp parameter, it is determined that the initial cache data and the cache parameter pass the validity detection.

[0099] The validity detection subunit is configured to determine that the initial cache data and the cache parameter pass the validity detection when the current time information is less than or equal to the cache timestamp parameter.

[0100] Further, the target cache data determination module 430 further comprises:

[0101] The initial return value generation unit is configured to execute the target method and generate the initial return value when the initial cache data does not exist in the preset storage library or the current time information is greater than the cache timestamp parameter.

[0102] Further, the target cache data determination module 430 further comprises:

[0103] The first target cache data generation unit is configured to extract a sensitive field set of the initial cache data and encrypt the sensitive field set to generate the target cache data when the return value is the target return value.

[0104] The second target cache data generation unit is configured to determine the initial cache data as the target cache data when the return value is the initial return value.

[0105] Further, the cache parameter configuration module 410 comprises:

[0106] The namespace identifier definition unit is configured to define a namespace identifier of the target method through the TypeScript decorator.

[0107] The storage information formulation unit is configured to formulate a data storage location and a data valid storage time of the target method through the TypeScript decorator.

[0108] The cache parameter determination unit is configured to determine the namespace identifier, the data storage location, and the data valid storage time as the cache parameters.

[0109] It should be noted that, for the convenience and brevity of description, the specific working processes of the above-described apparatus and modules can be referred to the corresponding processes in the foregoing method embodiments, and will not be described here.

[0110] The apparatus described above can be implemented in the form of a computer program, which can run on a computer device such as the computer device shown in Figure 3 .

[0111] Please refer to Figure 3 , Figure 3 is a structural schematic block diagram of a computer device provided by an embodiment of the present application. The computer device can be a server.

[0112] Refer to Figure 3 , the computer device includes a processor, a memory, and a network interface connected through a system bus, wherein the memory can include a non-volatile storage medium and an internal memory.

[0113] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions which, when executed, can cause the processor to perform any one of the TypeScript-based cache determination methods.

[0114] The processor is configured to provide computing and control capabilities to support the operation of the entire computer device.

[0115] The internal memory provides an environment for the execution of the computer program in the non-volatile storage medium, and the computer program, when executed by the processor, can cause the processor to perform any one of the TypeScript-based cache determination methods.

[0116] The network interface is configured to perform network communication, such as sending assigned tasks, etc. Those skilled in the art can understand that the structure shown in Figure 3 is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0117] It should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.

[0118] In one embodiment, the processor is configured to run a computer program stored in the memory to implement the following steps:

[0119] The target method is configured with a cache parameter through a preset open source programming language TypeScript decorator.

[0120] The calling instruction of the target method is intercepted through an interception instruction to generate a cache key associated with the calling instruction.

[0121] According to the cache parameter, the initial cache data corresponding to the cache key is read from a preset storage library, a return value is generated, and the target cache data is determined according to the return value.

[0122] In one embodiment, the calling instruction of the target method is intercepted through an interception instruction to generate a cache key associated with the calling instruction, which is used to implement:

[0123] The target method name of the target method is extracted, and the interception instruction is determined according to the target method name.

[0124] Each calling parameter in the calling instruction is parsed.

[0125] The calling parameter type and calling parameter value of each calling parameter are identified through the interception instruction.

[0126] According to the calling parameter type and the calling parameter value, the cache key is generated.

[0127] In one embodiment, according to the cache parameter, the initial cache data corresponding to the cache key is read from a preset storage library, a return value is generated, which is used to implement:

[0128] It is judged whether the initial cache data exists in the preset storage library, and a judgment result is generated.

[0129] In a case where the judgment result is that the initial cache data exists in the preset storage library, validity detection is performed on the initial cache data and the cache parameter.

[0130] In a case where the initial cache data and the cache parameter pass the validity detection, the target return value is generated according to the initial cache data and the cache parameter.

[0131] In an embodiment, in a case where the judgment result is that the initial cache data exists in the preset storage library, validity detection is performed on the initial cache data and the cache parameter, for realizing:

[0132] Obtaining current time information of the initial cache data;

[0133] Comparing the current time information and the cache timestamp parameter to generate a comparison result;

[0134] In a case where the current time information is less than or equal to the cache timestamp parameter, it is determined that the initial cache data and the cache parameter pass the validity detection.

[0135] In an embodiment, after judging whether the initial cache data exists in the preset storage library to generate a judgment result, for realizing:

[0136] If the initial cache data does not exist in the preset storage library, or the current time information is greater than the cache timestamp parameter, the target method is executed to generate the initial return value.

[0137] In an embodiment, according to the return value, target cache data is determined, for realizing:

[0138] In a case where the return value is the target return value, a sensitive field set of the initial cache data is extracted, and the sensitive field set is encrypted to generate the target cache data;

[0139] In a case where the return value is the initial return value, the initial cache data is determined as the target cache data.

[0140] In an embodiment, a cache parameter of a target method is configured through a preset open source programming language TypeScript decorator, for realizing:

[0141] A namespace identifier of the target method is defined through the TypeScript decorator;

[0142] A data storage location and a data valid storage time of the target method are formulated through the TypeScript decorator;

[0143] The namespace identification, the data storage location, and the data valid storage time are determined as the cache parameters.

[0144] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program. The computer program includes program instructions. The processor executes the program instructions to implement any one of the cache determination methods based on TypeScript provided by the embodiments of the present application.

[0145] The computer readable storage medium can be an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device. The computer readable storage medium can also be an external storage device of the computer device, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc.

[0146] The above merely describes the specific embodiments of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A TypeScript-based cache determination method, characterized in that, The method comprises the following steps: configuring a cache parameter for a target method through a preset open source programming language TypeScript decorator; intercepting a calling instruction of the target method through an intercepting instruction, and generating a cache key associated with the calling instruction; reading initial cache data corresponding to the cache key from a preset storage according to the cache parameter, generating a return value, and determining target cache data according to the return value.

2. The TypeScript-based cache determination method of claim 1, wherein, The method of intercepting the calling instruction of the target method through the intercepting instruction and generating the cache key associated with the calling instruction comprises the following steps: extracting a target method name of the target method, and determining the intercepting instruction according to the target method name; parsing each calling parameter in the calling instruction; identifying the calling parameter type and the calling parameter value of each calling parameter through the intercepting instruction; generating the cache key according to the calling parameter type and the calling parameter value.

3. The TypeScript-based cache determination method of claim 1, wherein, The return value comprises a target return value, and the method of reading the initial cache data corresponding to the cache key from the preset storage according to the cache parameter and generating a return value comprises the following steps: determining whether the initial cache data exists in the preset storage, and generating a determination result; in the case that the determination result is that the initial cache data exists in the preset storage, performing validity detection on the initial cache data and the cache parameter; in the case that the initial cache data and the cache parameter pass the validity detection, generating the target return value according to the initial cache data and the cache parameter.

4. The TypeScript-based cache determination method of claim 3, wherein, The cache parameter comprises a cache timestamp parameter, and the method of performing validity detection on the initial cache data and the cache parameter in the case that the determination result is that the initial cache data exists in the preset storage comprises the following steps: obtaining current time information of the initial cache data; comparing the current time information and the cache timestamp parameter, and generating a comparison result; in the case that the current time information is less than or equal to the cache timestamp parameter, determining that the initial cache data and the cache parameter pass the validity detection.

5. The TypeScript-based cache determination method of claim 4, wherein, The return value further comprises an initial return value, and after determining whether the initial cache data exists in the preset storage and generating a determination result, the method comprises the following steps: if the initial cache data does not exist in the preset storage or the current time information is greater than the cache timestamp parameter, executing the target method and generating the initial return value.

6. The TypeScript-based cache determination method of claim 5, wherein, The method of determining target cache data according to the return value comprises the following steps: in the case that the return value is the target return value, extracting a sensitive field set of the initial cache data, encrypting the sensitive field set, and generating the target cache data; in the case that the return value is the initial return value, determining the initial cache data as the target cache data.

7. The TypeScript-based cache determination method according to any one of claims 1 to 6, characterized in that, The method of configuring a cache parameter for a target method through a preset open source programming language TypeScript decorator comprises the following steps: defining a namespace identifier of the target method through the TypeScript decorator; The TypeScript decorator is used to determine a data storage location and a data valid storage time of the target method; The namespace identifier, the data storage location and the data valid storage time are determined as the cache parameter.

8. A TypeScript-based cache determination apparatus, characterized by, Comprise: A cache parameter configuration module is configured to configure a cache parameter for a target method by using a preset open source programming language TypeScript decorator; A cache key generation module is configured to intercept a calling instruction of the target method by using an interception instruction, and generate a cache key associated with the calling instruction; A target cache data determination module is configured to read initial cache data corresponding to the cache key from a preset storage library according to the cache parameter, generate a return value, and determine target cache data according to the return value.

9. A computer device, comprising: The computer device comprises a memory and a processor; The memory is configured to store a computer program; The processor is configured to execute the computer program and implement the TypeScript-based cache determination method in any one of claims 1 to 7 when the computer program is executed.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to make the processor implement the TypeScript-based cache determination method in any one of claims 1 to 7.