CN116450250B - Dynamic scenario execution method, system and storage medium - Google Patents

Dynamic scenario execution method, system and storage medium Download PDF

Info

Publication number
CN116450250B
CN116450250B CN202310713234.XA CN202310713234A CN116450250B CN 116450250 B CN116450250 B CN 116450250B CN 202310713234 A CN202310713234 A CN 202310713234A CN 116450250 B CN116450250 B CN 116450250B
Authority
CN
China
Prior art keywords
execution
identification
dynamic
data
result
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310713234.XA
Other languages
Chinese (zh)
Other versions
CN116450250A (en
Inventor
郑新
任文龙
陈烁隍
孔海明
王田丰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tianjin Jincheng Bank Ltd By Share Ltd
Original Assignee
Tianjin Jincheng Bank Ltd By Share Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tianjin Jincheng Bank Ltd By Share Ltd filed Critical Tianjin Jincheng Bank Ltd By Share Ltd
Priority to CN202310713234.XA priority Critical patent/CN116450250B/en
Publication of CN116450250A publication Critical patent/CN116450250A/en
Application granted granted Critical
Publication of CN116450250B publication Critical patent/CN116450250B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application relates to the technical field of Internet, in particular to a dynamic scenario execution method, a dynamic scenario execution system and a storage medium, wherein the method comprises the following steps: when executing the dynamic script obtained from the server, calculating to obtain the unique identifier of the text code of the dynamic script; detecting whether the unique identifier is contained in the historical execution data; and if the historical execution data contains the unique identifier, acquiring target execution data containing the unique identifier, obtaining an execution result of the dynamic scenario based on the target execution data, and returning the execution result. Therefore, the application can effectively solve the problems of low execution efficiency, low performance, high cost and the like when the dynamic execution script is adopted to realize the set function in the prior art.

Description

Dynamic scenario execution method, system and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method, a system, and a storage medium for executing dynamic scenarios.
Background
In some system designs, a dynamic script on a remote server is dynamically loaded at the back end of an application program, then the dynamic script is subjected to operations such as data type conversion and compiling, and finally the script is dynamically executed, a dynamic script file is stored in the server, the dynamic script file is acquired by the back end of the application program through a remote access server, and the dynamic script is executed after a plurality of columns such as data type conversion and compiling, so that a setting function is realized.
Among them, python is a scripting language widely used in the fields of data processing, machine learning, network programming, etc. The Python script needs to parse the code in the form of a string and then execute its code blocks, typically using exec () functions in Python to execute in real time and return the results. However, as the number and complexity of scripts increases, the execution efficiency and performance of this approach becomes a bottleneck and difficult to implement.
Some cache servers such as Memcached, redis are adopted in the prior art to solve the problems of low execution efficiency and low performance. But the scheme employing caching requires additional server support, increasing the complexity and maintenance costs of the system.
Disclosure of Invention
In view of this, embodiments of the present application provide a method, a system, and a storage medium for executing dynamic scenarios, which can effectively solve the problems of low execution efficiency, low performance, and high cost when the dynamic scenarios are adopted to implement the set function in the prior art.
In a first aspect, an embodiment of the present application provides a dynamic scenario execution method, including:
when executing the dynamic script obtained from the server, calculating to obtain the unique identifier of the text code of the dynamic script;
detecting whether the unique identifier is contained in the historical execution data;
and if the historical execution data contains the unique identifier, acquiring target execution data containing the unique identifier, obtaining an execution result of the dynamic scenario based on the target execution data, and returning the execution result.
In some embodiments, the historical execution data includes at least one of identification and result combination data, identification and instance combination data, identification and class object combination data;
the step of obtaining the execution result of the dynamic scenario based on the target execution data comprises the following steps:
if the target execution data is the combined data of the identification and the result, searching in the combined data of the identification and the result according to the unique identification to obtain an execution result of the dynamic script;
if the target execution data is the identification and instance combination data, searching in the identification and instance combination data according to the unique identification to obtain a class instance of the dynamic script; executing the dynamic script through the class instance to obtain an execution result;
if the target execution data is the combined data of the identification and the class object, searching the combined data of the identification and the class object according to the unique identification to obtain the class object of the dynamic script; and instantiating the class object to generate a class instance, and executing the dynamic script through the class instance to obtain an execution result.
In some embodiments, the identification and result combination data includes: the execution result of the dynamic scenario stored according to the unique identifier;
the identification and class object combination data comprises: a class object of the dynamic scenario stored according to the unique identifier;
the identification and example combination data comprise: and according to the unique identification, storing the class instance of the dynamic scenario.
In some embodiments, further comprising:
if the historical execution data does not contain the unique identifier, generating a class object according to the text code of the dynamic script; and instantiating the class object to obtain a class instance, executing the dynamic script through the class instance to obtain an execution result, and returning the execution result.
In some embodiments, the generating the corresponding class object according to the text code of the dynamic scenario includes:
decoding the text codes of the dynamic scripts to obtain character string codes of preset coding types;
and compiling the character string codes to obtain class objects in the form of byte codes.
In some embodiments, the dynamic scenario is executed through the class instance, and after the execution result is obtained, the method further includes:
if the history execution data contains the identification and class object combination data, after generating a class object, storing the class object into the identification and class object combination data according to the unique identification;
if the historical execution data comprises the identification and instance combination data, after generating a class instance, storing the class instance into the identification and instance combination data according to the unique identification;
and if the historical execution data comprises the identification and result combination data, after the execution result is obtained for the first time, storing the execution result into the identification and result combination data according to the unique identification.
In some embodiments, when the detection history execution data includes the unique identifier, the method further includes:
and detecting the identification and result combination data, the identification and instance combination data and the identification and class object combination data in sequence from front to back.
In some embodiments, the unique identification comprises a unique code; the unique code is a hash value of a text code of the dynamic scenario or a universal unique identification code of the dynamic scenario;
the unique identifier in the identifier and result combination data further comprises an item code set according to service function requirements, and the unique identifier is formed by using the item code and the unique code.
In a second aspect, an embodiment of the present application provides a dynamic scenario execution system, where the system includes a server and a client;
the server is used for storing dynamic scripts;
the client is used for acquiring the dynamic scenario from the server and implementing the dynamic scenario execution method provided by the first aspect of the present application.
In a third aspect, an embodiment of the present application provides a readable storage medium storing a computer program, where the computer program implements a dynamic scenario execution method provided in the first aspect of the present application when the computer program is executed on a processor.
The embodiment of the application has the following beneficial effects:
according to the method, whether the historical execution data contain the unique identification is detected, then the target execution data are obtained according to the unique identification, and the execution result of the dynamic script is obtained based on the target execution data. In the process, time-consuming processing such as decoding and compiling is not needed for the text codes of the dynamic scripts, unnecessary script execution is reduced by fully utilizing the historical execution data, the execution efficiency of the program is improved, meanwhile, the cached historical execution data is stored in the program, no additional server support is needed, the cost is reduced, and the complexity and the maintenance cost of the system are reduced while the maintenance is convenient.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 illustrates a flow chart of a dynamic scenario execution method of an embodiment of the present application;
FIG. 2 is a flow chart showing a dynamic scenario execution method according to an embodiment of the present application in executing a dynamic scenario for the first time;
FIG. 3 is a flow chart showing a method for executing dynamic scenarios in accordance with an embodiment of the present application when dynamic scenarios are not executed for the first time;
FIG. 4 is a block diagram showing a configuration of a dynamic scenario execution apparatus according to an embodiment of the present application;
FIG. 5 illustrates a system block diagram of a dynamic scenario execution system of an embodiment of the present application.
Description of main reference numerals:
1-a server side; 2-a client; 410-a calculation module; 420-a detection module; 430-a result acquisition module.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments.
The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art without making any inventive effort, are intended to be within the scope of the present application.
The terms "comprises," "comprising," "including," or any other variation thereof, are intended to cover a specific feature, number, step, operation, element, component, or combination of the foregoing, which may be used in various embodiments of the present application, and are not intended to first exclude the presence of or increase the likelihood of one or more other features, numbers, steps, operations, elements, components, or combinations of the foregoing. Furthermore, the terms "first," "second," "third," and the like are used merely to distinguish between descriptions and should not be construed as indicating or implying relative importance.
Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which various embodiments of the application belong. The terms (such as those defined in commonly used dictionaries) will be interpreted as having a meaning that is the same as the context of the relevant art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein in connection with the various embodiments of the application.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The embodiments described below and features of the embodiments may be combined with each other without conflict.
According to the Python language as an example, the process of executing dynamic scenario in the prior art is: 1) And acquiring the text code of the dynamic script from the remote server 1, wherein the text code of the dynamic script is of a byte array type. 2) And then, decoding the dynamic script text codes of the byte array type by adopting a function decode ("utf 8") function, and converting the dynamic script text codes into utf8 coding character string codes. 3) And compiling scripts for the character string codes by adopting a function combile () to obtain byte codes. 4) And executing the dynamic script of the byte code type by using the function exec () to obtain an execution result. Steps 2) to 4) in this process are very time-consuming processes, and frequent execution of this process may result in a decrease in performance of the application program, resulting in a low script execution efficiency. Therefore, the application provides a dynamic scenario execution method, a dynamic scenario execution system and a storage medium, which can effectively solve the problems of low execution efficiency, low performance, high cost and the like when the dynamic scenario is adopted to realize the set function in the prior art.
The dynamic scenario execution method is described below in connection with some specific embodiments.
FIG. 1 shows a flow chart of a dynamic scenario execution method of an embodiment of the present application. The dynamic scenario execution method exemplarily comprises the following steps:
s10, when the dynamic scenario acquired from the server side 1 is executed, the unique identification of the text code of the dynamic scenario is calculated.
When the dynamic script of the server side 1 is updated, the client side 2 synchronously updates and downloads the dynamic script. The unique identifier is updated synchronously with the dynamic scenario.
The embodiment does not limit the specific manner of the unique identifier, and the unique identifier may be a unique identifier set according to a rule, for example, a dynamic scenario for implementing addition calculation is marked as a 0 Dynamic scenario implementing subtraction computation is labeled B 0 Similarly, when dynamic scenario update of addition calculation is realized, the corresponding mark is synchronously updated to A 1
Specifically, the unique identification comprises a unique code; the unique code may be a hash value of a text code of the dynamic scenario or a universal unique identification code UUID that is automatically generated when the dynamic scenario uploads to the server. And obtaining the hash value of the text code of the dynamic script by adopting an MD5 algorithm.
S20, detecting whether the historical execution data contains a unique identifier.
S30, if the historical execution data contains the unique identifier, acquiring target execution data containing the unique identifier, acquiring an execution result of the dynamic scenario based on the target execution data, and returning the execution result.
In one embodiment, the historical execution data includes at least one of identification and result combination data, identification and instance combination data, identification and class object combination data.
The identification and result combination data comprises an execution result corresponding to the dynamic scenario stored according to the unique identification. The dynamic script is called for the first time, an execution result is obtained, a unique identifier is obtained through calculation, and the unique identifier is stored in the identifier and result combination data.
The identification and class object combination data comprises class objects corresponding to dynamic scripts stored according to the unique identification. And after the dynamic script is downloaded from the server, calculating to obtain a unique identifier of the dynamic script, and storing the unique identifier into the identifier and class object combination data according to the unique identifier.
The identification and instance combination data comprises class instances corresponding to dynamic scripts stored according to the unique identification. When the dynamic script is called for the first time, the class instance is obtained after being instantiated, the unique identifier is obtained through calculation, and the unique identifier is stored into the identifier and instance combination data.
In this embodiment, the identification and result combination data, the identification and instance combination data, the identification and class object combination data are all stored by using dictionary data types, and the unique identification is used as a key of the dictionary. The data types of the identification and result combination data, the identification and instance combination data, and the identification and class object combination data are not limited in this embodiment, and may be, for example, a list, a tuple, a set, and the like stored in a form of a key value pair.
In general, the same dynamic scenario is suitable for multiple cases (or called projects), so that the multiple cases can repeatedly use historical execution data, and further, the unique identifier in the identifier and result combination data also comprises project codes set according to service function requirements. That is, the unique identifier in the identifier and result combination data is the item code+the unique code. The unique identifier in the identifier and instance combination data and the identifier and class object combination data is a unique code. For example, a dynamic scenario requiring an authentication event identity function is applicable to both event a and event B. After the event A executes the dynamic scenario, the execution result is only suitable for being used when the event A authenticates next time because the execution result contains information unique to the event A, and the class instance and the class object do not contain unique information and can be used when the event B authenticates, so that the time for the event B to execute the dynamic scenario is reduced.
In one embodiment, if the historical execution data includes identification and result combination data, identification and instance combination data, and identification and class object combination data. When detecting whether the unique identifier is included in the history execution data in step S20, the method further includes:
and detecting the identification and result combination data, the identification and instance combination data and the identification and class object combination data in sequence from front to back.
The execution result in the identification and result combination data, the class instance in the identification and instance combination data and the class object in the identification and class object combination data have different generating and obtaining time, the class object is obtained firstly, and the class object can be obtained through a series of processing after being downloaded from the server side 1. Then, the class instance and the execution result can be obtained when the dynamic scenario is executed for the first time. In order to reduce the execution time of dynamic scenarios, the identification and result combination data is preferentially detected.
In one embodiment, the step S30 of obtaining the execution result of the dynamic scenario based on the target execution data includes:
if the target execution data is the combined data of the identifier and the result, searching in the combined data of the identifier and the result according to the unique identifier to obtain an execution result of the dynamic script;
or if the target execution data is the identification and instance combination data, searching in the identification and instance combination data according to the unique identification to obtain a class instance of the dynamic script; executing the dynamic script through the class instance to obtain an execution result;
or if the target execution data is the combined data of the identifier and the class object, searching the combined data of the identifier and the class object according to the unique identifier to obtain the class object of the dynamic script; and instantiating the class object to obtain a class instance, and executing the dynamic script through the class instance to obtain an execution result.
The historical execution data can only comprise one or two of identification and result combination data, identification and instance combination data and identification and class object combination data.
It can be understood that after the dynamic scenario is executed by the class instance, the method further includes:
if the historical execution data comprises the identification and class object combination data, after generating a class object according to the text code of the dynamic script, storing the class object into the identification and class object combination data according to the unique identification;
if the history execution data comprises the identification and the instance combination data, after the class object is instantiated to generate a class instance, the class instance is stored into the identification and the instance combination data according to the unique identification;
if the historical execution data comprises the identification and result combination data, the dynamic script is executed through the class instance, and after the execution result is obtained, the execution result is stored into the identification and result combination data according to the unique identification.
In one embodiment, if the historical execution data does not contain a unique identifier, generating a corresponding class object according to the text code of the dynamic scenario; the class object is instantiated to obtain a class instance, the dynamic script is executed through the class instance to obtain an execution result, and the execution result is returned. For example, when the dynamic scenario is executed for the first time, the historical execution data does not contain a unique identifier, and after the dynamic scenario is executed, the execution result is stored into the historical execution data according to the unique identifier.
The method for generating the corresponding class object according to the text code of the dynamic script comprises the following steps:
and decoding the text codes of the dynamic scripts to obtain character string codes of preset coding types. And compiling the character string codes to obtain class objects in the form of byte codes. For example, in the Python language, the decoding process is performed by using a function decoder ("utf 8"), and the character string code is compiled by using a function command ().
The application is described below by way of a specific application scenario: the application scene is realized by adopting a Python language, the historical execution data comprises identification and result combination data, identification and instance combination data and identification and class object combination data, and the data type adopts a dictionary data type.
Assume that a class Cache representing a Cache is defined, and 3 dictionary objects are defined in the class Cache: class_caches, value_caches, and instance_caches. The class_caches are used for storing the identification and class object combination data, hash values of text codes of dynamic scripts are used as unique identifications, and key value pairs in a class_caches dictionary are used as unique identifications and class objects of the dynamic scripts. The value_caches are used for storing the data of the combination of the identification and the result, the mode of the case number and the hash value is adopted as the unique identification, and key value pairs in the value_caches dictionary are the unique identification and the execution result of the dynamic script. The instance_caches are used for storing the identification and instance combination data, hash values are used as unique identifications, and key value pairs in the instance_caches dictionary are used as unique identifications and class instances of dynamic scripts.
First case: the dynamic scenario is executed for the first time, as shown in fig. 2, comprising the following steps:
s210, generating a corresponding class object according to the text code of the dynamic scenario, wherein the dynamic scenario is determined according to the service function requirement.
In this step, classa=exec (comble (class classA: defmain (): return a+b "))) can be used, and this is directly obtained. Specifically, (1) the text code of the dynamic scenario is a byte array, which is denoted as code_bytes, decoding is performed by using a code_bytes.decode ("utf 8") function, and the byte array is converted into a character string, so as to obtain a character string code of utf8 type coding, which is denoted as raw_code.
(2) And calculating the hash value of the raw_code by adopting an MD5 function to obtain a hash value hash_key.
(3) The dynamic scenario is compiled using a command (raw_code, set path, 'exec') function, resulting in byte Code byte_code.
(4) Dictionary ns= { } is defined, which is a global method and variable dictionary available, and dynamic scenarios are executed using exec (byte_code, ns). Class objects are contained within dictionary ns.
(5) Class objects cls are found by looking up in the dictionary ns.
S220, generating a corresponding class object according to the text code of the dynamic scenario. For example, aaa=classa (), the class object classA described above is instantiated. Also, for example, class objects are instantiated by cls_obj=cls (), generating class instance cls_obj.
S230, executing the dynamic script through the class instance to obtain an execution result, and returning the execution result. Specifically, a dynamic script is executed through result=cls_obj.function (), and an execution result is obtained, wherein function is a fixed method, and the fixed method is directly called by default.
S240, storing the historical execution data containing the execution result, the class object and the class instance into a corresponding dictionary.
Correspondingly, the execution result is stored in value_caches, the generated class object is stored in class_caches, and the class instance is stored in instance_caches. Specifically, class object cls is stored in the class_cache by self_cache [ casenum+hash_key ] =cls, where CaseNum is a case number. Class instances are stored in instance_cache by self.instance_cache [ hash_key ] = cls_obj. The execution result is stored into the value_cache by self_cache [ hash_key ] =result.
Second case: the non-first execution dynamic scenario, as shown in FIG. 3, includes the following steps:
s310, calculating a unique identifier. And selecting the dynamic scenario to be executed according to the case requirement, and calculating the hash value of the text code from the dynamic scenario before executing the dynamic scenario. Naturally, the unique identifier in value_caches is case number+hash value, and the unique identifiers of instance_caches and class_caches directly use hash value.
S320, judging whether a unique identifier exists in the identifier and the result combination data. If so, acquiring the execution result stored in the combined data of the identification and the result according to the unique identification.
Specifically, whether the unique identifier exists in the value_caches is searched, if the unique identifier exists in the value_caches, the dynamic scenario is executed, and the execution result of the dynamic scenario stored in the value_caches is obtained according to the unique identifier.
If there is no unique identifier in value_matches, step S330 is performed.
S330, judging whether a unique identifier exists in the identifier and the class object combination data.
If so, searching the identification and class object combination data according to the unique identification to obtain a class object of the dynamic script; and instantiating the class object to obtain a class instance, and executing the dynamic script through the class instance to obtain an execution result.
Specifically, whether a unique identifier exists in the instance_caches is searched, if the unique identifier exists in the instance_caches, a class instance of the dynamic script stored in the instance_caches is obtained according to the unique identifier, and the dynamic script is executed through the class instance, so that an execution result is obtained. And the unique identifier and the execution result are formed into a key value pair to be stored into the value_caches.
If there is no unique identifier in instance_matches, step S340 is performed.
S340, generating a class object according to the dynamic scenario text code, instantiating the class object to obtain a class instance, and executing the dynamic scenario through the class instance to obtain an execution result.
Specifically, whether a unique identifier exists in the class_caches is searched, if the unique identifier exists in the class_caches, class objects stored in the class_caches are acquired according to the unique identifier, the class objects are instantiated, class instances are generated, dynamic scripts are executed through the class instances, and an execution result is obtained. And the unique identifier and the execution result are formed into a key value pair to be stored in value_caches, and the unique identifier and the generated class instance are formed into a key value pair to be stored in instance_caches.
If there is no unique identifier in class_matches, step S350 is performed.
S350, generating a corresponding class object according to the text code of the dynamic scenario, instantiating the class object to obtain a class instance, executing the dynamic scenario through the class instance to obtain an execution result, and returning the execution result. The unique identifier and the execution result are formed into a key value pair to be stored in value_caches, the unique identifier and the generated class instance are formed into a key value pair to be stored in instance_caches, and the unique identifier and the generated class object are formed into a key value pair to be stored in class_caches.
Regarding the storage management of the dictionary class_caches, the value_caches and the instance_caches, the method is not limited in deleting the data in the dictionary, and if the data need to be deleted, the old unique identifier can be found according to the dynamic script file name or other data, and the data can be directly deleted according to the old unique identifier. However, some scripts which pass the audit and are run by the application server are rarely modified according to the actual condition of the project and are not required to be deleted, the number of the scripts is fixed, and the unique identification is rarely changed.
The method is suitable for all Python application programs for executing dynamic scripts, and is particularly suitable for dynamic scripts with relatively stable script codes and higher execution frequency.
The method comprises the steps of sequentially detecting whether unique identifiers are contained in the identifier and result combination data, the identifier and instance combination data and the identifier and class object combination data, obtaining target execution data according to the unique identifiers, and obtaining the execution result of the dynamic script based on the target execution data. The time-consuming processes such as decoding, compiling and the like of the dynamic script are not needed each time the dynamic foot is executed. The application can reduce unnecessary script execution by fully utilizing the history execution data and improve the execution efficiency of the program. Meanwhile, the cached historical execution data is stored in the program without additional server support, so that the cost is reduced, and the system complexity and the maintenance cost can be reduced while the maintenance is convenient.
Fig. 4 is a schematic diagram showing a configuration of a dynamic scenario execution apparatus according to an embodiment of the present application. Illustratively, the dynamic scenario execution apparatus includes: a calculation module 410, a detection module 420, and a result acquisition module 430.
The calculation module 410 is configured to calculate, when executing the dynamic scenario acquired from the server 1, a unique identifier of a text code of the dynamic scenario.
The detection module 420 is configured to detect whether the historical execution data includes a unique identifier.
The result obtaining module 430 is configured to obtain, when the historical execution data includes a unique identifier, target execution data including the unique identifier, obtain an execution result of the dynamic scenario based on the target execution data, and return the execution result.
It will be appreciated that the apparatus of this embodiment corresponds to the dynamic scenario execution method of the above embodiment, and the options in the above embodiment are also applicable to this embodiment, so the description will not be repeated here.
The application also provides a dynamic scenario execution system, which exemplarily comprises a server 1 and a client 2 as shown in fig. 5;
the server 1 is used for storing dynamic scripts. The client 2 is configured to obtain a dynamic scenario from the server 1, and is further configured to implement a dynamic scenario execution method in the foregoing embodiment.
It will be appreciated that the system of the present embodiment corresponds to the dynamic scenario execution method of the above embodiment, and the options in the above embodiment are equally applicable to the present embodiment, so the description will not be repeated here.
The present application also provides a terminal device, which exemplarily includes a processor and a memory, where the memory stores a computer program, and the processor executes the computer program, so that the terminal device executes the above dynamic scenario execution method or the functions of each module in the above dynamic scenario execution apparatus.
The processor may be an integrated circuit chip with signal processing capabilities. The processor may be a general purpose processor including at least one of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU) and a network processor (Network Processor, NP), a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like that may implement or perform the methods, steps, and logic blocks disclosed in embodiments of the present application.
The Memory may be, but is not limited to, random access Memory (Random Access Memory, RAM), read Only Memory (ROM), programmable Read Only Memory (Programmable Read-Only Memory, PROM), erasable Read Only Memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc. The memory is used for storing a computer program, and the processor can correspondingly execute the computer program after receiving the execution instruction.
The present application also provides a readable storage medium storing the computer program for use in the above terminal device.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, of the flow diagrams and block diagrams in the figures, which illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules or units in various embodiments of the application may be integrated together to form a single part, or the modules may exist alone, or two or more modules may be integrated to form a single part.
The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a smart phone, a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present application.

Claims (7)

1. A dynamic scenario execution method, comprising:
when executing the dynamic script obtained from the server, calculating to obtain the unique identifier of the text code of the dynamic script;
detecting whether the unique identifier is contained in the historical execution data;
if the historical execution data contains the unique identifier, acquiring target execution data containing the unique identifier, acquiring an execution result of the dynamic script based on the target execution data, and returning the execution result;
wherein, the history execution data comprises identification and result combination data, identification and instance combination data and identification and class object combination data; the unique identification comprises a unique code; the unique code is a hash value of a text code of the dynamic scenario; the unique identifier in the identifier and result combination data also comprises an item code set according to service function requirements, the unique identifier is formed by using the item code and the unique code, and the unique identifier containing the item code is marked as a result unique identifier;
the step of obtaining the execution result of the dynamic scenario based on the target execution data comprises the following steps:
if the target execution data is the combined data of the identifier and the result, searching in the combined data of the identifier and the result according to the unique identifier of the result to obtain an execution result of the dynamic script;
if the target execution data is the identification and instance combination data, searching in the identification and instance combination data according to the unique identification to obtain a class instance of the dynamic script; executing the dynamic script through the class instance to obtain an execution result;
if the target execution data is the combined data of the identification and the class object, searching the combined data of the identification and the class object according to the unique identification to obtain the class object of the dynamic script; and instantiating the class object to generate a class instance, and executing the dynamic script through the class instance to obtain an execution result.
2. The dynamic scenario execution method according to claim 1, further comprising:
if the historical execution data does not contain the unique identifier, generating a class object according to the text code of the dynamic script;
and instantiating the class object to obtain a class instance, executing the dynamic script through the class instance to obtain an execution result, and returning the execution result.
3. The dynamic scenario execution method according to claim 2, wherein the generating the corresponding class object according to the text code of the dynamic scenario comprises:
decoding the text codes of the dynamic scripts to obtain character string codes of preset coding types;
and compiling the character string codes to obtain class objects in the form of byte codes.
4. A dynamic scenario execution method according to claim 2 or 3, wherein the dynamic scenario is executed by the class instance, and further comprising, after the execution result is obtained:
if the history execution data contains the identification and class object combination data, after generating a class object, storing the class object into the identification and class object combination data according to the unique identification;
if the historical execution data comprises the identification and instance combination data, after generating a class instance, storing the class instance into the identification and instance combination data according to the unique identification;
and if the historical execution data comprises the identification and result combination data, after the execution result is obtained for the first time, storing the execution result into the identification and result combination data according to the result unique identification.
5. The dynamic scenario execution method according to claim 4, wherein when the unique identifier is included in the detection history execution data, further comprising:
and detecting the identification and result combination data, the identification and instance combination data and the identification and class object combination data in sequence from front to back.
6. A dynamic scenario execution system is characterized by comprising a server and a client;
the server is used for storing dynamic scripts;
the client is used for acquiring the dynamic scenario from the server and implementing the dynamic scenario execution method of any one of claims 1-5.
7. A readable storage medium, characterized in that it stores a computer program which, when executed on a processor, implements the dynamic scenario execution method according to any one of claims 1-5.
CN202310713234.XA 2023-06-16 2023-06-16 Dynamic scenario execution method, system and storage medium Active CN116450250B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310713234.XA CN116450250B (en) 2023-06-16 2023-06-16 Dynamic scenario execution method, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310713234.XA CN116450250B (en) 2023-06-16 2023-06-16 Dynamic scenario execution method, system and storage medium

Publications (2)

Publication Number Publication Date
CN116450250A CN116450250A (en) 2023-07-18
CN116450250B true CN116450250B (en) 2023-09-19

Family

ID=87127705

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310713234.XA Active CN116450250B (en) 2023-06-16 2023-06-16 Dynamic scenario execution method, system and storage medium

Country Status (1)

Country Link
CN (1) CN116450250B (en)

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6308320B1 (en) * 1999-01-15 2001-10-23 Hewlett-Packard Company Method and apparatus for incremental selective compilation of intermediate code files during computer system compilation and linking
CN103412754A (en) * 2013-08-15 2013-11-27 优视科技有限公司 Dynamic language code execution method and device
CN108228231A (en) * 2018-01-08 2018-06-29 南京邮电大学 A kind of visualization shift algorithm of Git warehouses file annotation system
CN108880820A (en) * 2018-06-01 2018-11-23 中国联合网络通信集团有限公司 Code administration method and apparatus
CN109325194A (en) * 2018-07-03 2019-02-12 优视科技有限公司 Page access method, apparatus, equipment and storage medium
CN111201752A (en) * 2017-08-11 2020-05-26 塞库尔开放系统公司 Data verification system based on Hash
CN111309756A (en) * 2020-04-24 2020-06-19 北京信安世纪科技股份有限公司 Database script encoding and decoding methods and devices
CN114115895A (en) * 2021-11-23 2022-03-01 深圳Tcl新技术有限公司 Code query method and device, electronic equipment and storage medium
CN114579107A (en) * 2022-03-11 2022-06-03 北京字跳网络技术有限公司 Data processing method, device, equipment and medium
CN114721807A (en) * 2022-04-22 2022-07-08 中国工商银行股份有限公司 Batch business task execution method, device, equipment, medium and program product
CN114791826A (en) * 2022-04-11 2022-07-26 亿玛创新网络(天津)有限公司 Jenkins project operation method and device based on parameter configuration
CN114996279A (en) * 2022-06-27 2022-09-02 深圳前海微众银行股份有限公司 Method and device for optimizing sql script
CN115390846A (en) * 2022-08-11 2022-11-25 地平线(上海)人工智能技术有限公司 Compiling construction method and device, electronic equipment and storage medium
CN116257426A (en) * 2021-12-10 2023-06-13 中国联合网络通信集团有限公司 Test association method, device, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9117071B2 (en) * 2009-06-03 2015-08-25 Apple Inc. Methods and apparatuses for secure compilation
US20130041900A1 (en) * 2011-08-10 2013-02-14 Bank Of America Corporation Script Reuse and Duplicate Detection

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6308320B1 (en) * 1999-01-15 2001-10-23 Hewlett-Packard Company Method and apparatus for incremental selective compilation of intermediate code files during computer system compilation and linking
CN103412754A (en) * 2013-08-15 2013-11-27 优视科技有限公司 Dynamic language code execution method and device
CN111201752A (en) * 2017-08-11 2020-05-26 塞库尔开放系统公司 Data verification system based on Hash
CN108228231A (en) * 2018-01-08 2018-06-29 南京邮电大学 A kind of visualization shift algorithm of Git warehouses file annotation system
CN108880820A (en) * 2018-06-01 2018-11-23 中国联合网络通信集团有限公司 Code administration method and apparatus
CN109325194A (en) * 2018-07-03 2019-02-12 优视科技有限公司 Page access method, apparatus, equipment and storage medium
CN111309756A (en) * 2020-04-24 2020-06-19 北京信安世纪科技股份有限公司 Database script encoding and decoding methods and devices
CN114115895A (en) * 2021-11-23 2022-03-01 深圳Tcl新技术有限公司 Code query method and device, electronic equipment and storage medium
CN116257426A (en) * 2021-12-10 2023-06-13 中国联合网络通信集团有限公司 Test association method, device, electronic equipment and storage medium
CN114579107A (en) * 2022-03-11 2022-06-03 北京字跳网络技术有限公司 Data processing method, device, equipment and medium
CN114791826A (en) * 2022-04-11 2022-07-26 亿玛创新网络(天津)有限公司 Jenkins project operation method and device based on parameter configuration
CN114721807A (en) * 2022-04-22 2022-07-08 中国工商银行股份有限公司 Batch business task execution method, device, equipment, medium and program product
CN114996279A (en) * 2022-06-27 2022-09-02 深圳前海微众银行股份有限公司 Method and device for optimizing sql script
CN115390846A (en) * 2022-08-11 2022-11-25 地平线(上海)人工智能技术有限公司 Compiling construction method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN116450250A (en) 2023-07-18

Similar Documents

Publication Publication Date Title
US8543543B2 (en) Hash-based file comparison
CN107948314B (en) Business processing method and device based on rule file and server
CN107729227B (en) Application program test range determining method, system, server and storage medium
US8839420B2 (en) Validation of function call parameters
WO2013109555A1 (en) Managing script file dependencies and load times
CN110023938B (en) System and method for determining file similarity by using function length statistics
US20190087208A1 (en) Method and apparatus for loading elf file of linux system in windows system
CN110866198A (en) Static resource caching method, system, device, computer equipment and storage medium
CN114467083A (en) Customized root process for application community
CN107577943B (en) Sample prediction method and device based on machine learning and server
CN113590144B (en) Dependency processing method and device
CN113608800A (en) Project starting method and device, electronic equipment and storage medium
CN116450250B (en) Dynamic scenario execution method, system and storage medium
CN106502707B (en) Code generation method and device
CN108959915B (en) Rootkit detection method, rootkit detection device and server
CN107451050B (en) Function acquisition method and device and server
CN114611039B (en) Analysis method and device of asynchronous loading rule, storage medium and electronic equipment
US10505739B2 (en) Prefix fingerprint
CN115858186A (en) Shared resource access method, system, electronic device and storage medium
CN110929188A (en) Method and device for rendering server page
CN114296747A (en) Installation method and device of software installation package
CN112395299A (en) Data updating method and device, terminal equipment and storage medium
CN109308299B (en) Method and apparatus for searching information
CN107122164B (en) Method, device, equipment and storage medium for acquiring function address and applying function address
CN112800194A (en) Interface change identification method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant