The Caché Application Server offers advanced object programming capabilities, provides sophisti-cated data caching, and integrates easy access to a variety of technologies. The Caché Application Server makes it possible to develop sophisticated database applications rapidly, operate them with high performance, and support them easily.
More specifically, the Caché Application Server provides
The core of the Caché Application Server is the extremely fast Caché Virtual Machine, which supports Caché’s two scripting languages – Caché ObjectScript and Basic.
Database access within the Caché Virtual Machine is highly optimized. Each user process in the Caché Virtual Machine has direct access to the multidimensional data structures by making calls to shared memory that access a shared database cache. All other technologies (Java, C++, ODBC, JDBC, etc.) connect through the Caché Virtual Machine to access the database.
Complete Interoperability
Since both Caché ObjectScript and Basic are implemented on the same Caché Virtual Machine, they are completely interoperable:
Faster Development / Flexible Deployment
In almost all cases, programmers can develop applications faster, and those applications will run significantly faster with greater scalability, by writing as much code as possible in these scripting languages – Caché ObjectScript and Basic – so that they run in the Caché Virtual Machine. Plus, such code requires no changes to switch hardware or operating systems. Caché automatically handles all differences in operating system and hardware.
The Caché AdvantageRapid Application Development Development of complex database applications with Caché ObjectScript is radically faster than any other major language – often 10 to 100 times faster. Faster also means the project has a better chance of succeeding – with fewer programmers – and being able to adjust rapidly as application needs change. Shorter Learning Curve Basic is perhaps the world’s best known computer language. Developers who know Visual Basic can instantly start writing code in Basic, and the Caché object model is easily learned. Faster and More Scalable The Caché Virtual Machine with its direct access to the database provides faster applications that can scale to tens of thousands of users using low-cost hardware. Flexibility Code that runs in the Caché Virtual Machine can run on other hardware and operating systems without change. Code is stored in the database and automatically propagated to Application Servers. |
Caché ObjectScript is a powerful, object-oriented programming language designed for rapid development of database applications. Here are some of the key characteristics of the language.
Overall Structure
Caché ObjectScript is command oriented; hence it has syntax such as:
set x=a+b
do rotate(a,3)
if (x>3)
There is a set of built-in system functions that are particularly powerful for text manipulation. Their names all start with the single ‘$’ character to distinguish them from variable and array names. For example:
|
|
|
|
|
|
|
Expressions use left-to-right operator precedence, just like most hand-held calculators, except when parentheses alter the order of evaluation.
Flexible Data Storage
One of the most unique characteristics of Caché ObjectScript is its highly flexible and dynamic data storage. Data may be stored in:
With rare exceptions, any place in the language where a variable can be used, an array, object property, or global reference could also be used.
In most computer languages, datatypes are an extension of hardware storage concepts (integer, float, char, etc.). However, Caché ObjectScript has the philosophy that humans don’t think using such storage types, and that these “computer-centric” datatypes simply impede rapid application development. Requiring declarations and dimension statements introduces far more errors than they help prevent (errors such as a 2-byte integer overflow, or when a string overflows its alloca-tion of memory and corrupts other storage). However, object typing, such as Person, Invoice, or Animal, is viewed as highly valuable and consistent with the way humans think.
Thus, in Caché ObjectScript, object properties are strongly typed, but the other three types of storage (variables, arrays, and global nodes) are fully polymorphic, typeless entities that need not be declared or defined. They simply pop into existence as they are used and mold themselves to the data needs of what they are storing and how they are being used in an expression. Even arrays do not need any specification of size or dimension or type of subscripts or data. For example, a developer might create an array called Person by simply setting:
set Person(”Smith”,”John”)=”I’m a good person”
In this example, data was stored in a two-dimensional array using string data for subscripts. Other data nodes in this array might have a different number of dimensions and might intermix strings, integers, or other types of data for subscripts. For example, one might store data in:
abc(3)
abc(3,-45.6,”Yes”)
abc(”Count”)
all in the same array.
Direct Access to the Database
A direct reference to the database (a “global reference”) is essentially a multidi-mensional array reference preceded by the carat character ‘^’. That character indicates this is a reference to data stored in the database rather than to tempo-rary process private data. Each such database array is called a “global”.
As with multidimensional arrays and variables, no declarations or definitions or reservations of storage are required to access or store data in the database; global data simply pops into existence as data is stored. For example, to store information in the database one might write:
set ^Person(”Smith”,”John”)=”I’m a very good person”
and later might retrieve it by code such as:
set x=^Person(”Smith”,”John”)
The programmer has complete flexibility in how to structure these global data arrays. (See the Multidimensional Data Model.)
Object References
Caché Objects implement the ODMG data model with powerful extensions.
In Caché ObjectScript an “oref” is used to access an object (an
“oref” is typically a variable whose value specifies which in-memory object
is being referenced). The “oref” is followed by a dot and then by the name
of a property or method. Object references can be used wherever an expres-sion
can be used. For example:
|
|
|
|
|
|
|
|
|
Methods can also be executed with a DO command when no return value is needed. For example:
|
|
The “oref” is not the same as a database object ID. The object ID is a value that is permanently associated with a database object; it is used to retrieve and store a database object. Once an object is in memory, it is assigned a reusable oref value that is then used to access the object’s data. The next time that same database object is brought into memory it will probably be assigned a different oref value.
HTML and SQL Access
HTML for Web applications and SQL can be embedded in Caché ObjectScript code.
Calling Code
In some object languages, all code has to be part of some method. Caché ObjectScript doesn’t have that restriction – code may be directly called or called through object syntax.
Code is often called using the DO command.
do rotate(a,3)
Code that returns a value can also be called as a function. For example,
set x=a+$$insert(3,y)
calls the programmer-written procedure or subroutine “insert”.
Code can also be invoked as an object method.
|
|
|
|
|
|
|
|
|
Both call by value and call by reference is supported for parameters.
Routines
Caché ObjectScript code is fundamentally organized into a set of “routines”. Each routine (typically up to 32kb in size) is atomic in the sense that it can be independently edited, stored, and compiled. Routines are linked dynamically at runtime; there is no separate linking step for the programmer. Routine code is stored in the database; thus, routines can be dynamically paged across the network rather than having to be installed on each computer.
Within a routine, code is organized as a set of procedures and/or subroutines. (An object method is a procedure, but it is accessed by a different syntax.)
When calling code that is within the same routine, only the procedure or subroutine name is needed. Otherwise, the routine name must be appended to it.
|
|
|
|
A procedure or subroutine that has a return value of interest should be called using the “$$” function syntax.
|
|
Routines can be edited and compiled through the Caché Studio.
Object Methods
Class definitions and their method code are stored in global data files, and the Class Compiler compiles each class into one or more routines. Each method is simply a procedure in a routine, although it can only be invoked by object syntax. For instance, if the Patient class defines an Admit method and the Pat variable identifies a specific Patient object, then we call the Admit method for that object with the following syntax:
|
|
|
|
Procedures and Public/Private Variables
A procedure is a block of code within a routine that is similar to a function in other languages. A procedure consists of a name, a formal parameter list, a list of public variables, and a block of code delimited by ‘{}’. For example:
Admit(x,y)[name,recnum] { ...code goes here}
In Caché ObjectScript, some variables are common and others are private to a particular proce-dure. Every variable that is used within a procedure is considered private to that procedure unless it is listed in the public list. In the above example, ‘name’ and ‘recnum’ access the public variables by those names, whereas all other variables exist only for this invocation of this procedure. Variable names that start with a ‘%’ character are always implicitly public.
Procedures cannot be nested, although a procedure can contain subroutines.
Subroutines
Routines may also contain subroutines, which are lighter weight than procedures. A subroutine may contain a parameter list and it may return a value, but it does not have a public list or formal block structure. Subroutines may be embedded within procedures or be at the same level as a procedure in a routine.
Subroutines permit the calling of code using the same public/private set of variables as the caller, and they can be called quicker. A subroutine embedded within a procedure uses the same variable scope as the proce-dure and may only be called from within that proce-dure. Variable references for a subroutine that is not part of a procedure are all to public variables.
BASIC
Basic is perhaps the world’s best-known application programming language. In Caché, Basic has been extended to support direct access of the Data Server’s core data structures – multidimen-sional Array – as well as other Caché Application Server features. It directly supports the Caché Object Model using Visual Basic syntax, and runs in the Caché Virtual Machine.
Basic can be used either as methods of classes or as Caché routines (see the Caché ObjectScript description of routines.) Basic can call Caché ObjectScript, and vice-versa, with both languages accessing the same variables, arrays, and objects in process memory.
Arrays have been extended to be far more powerful:
A(“colors”)
and
A(“colors”,3)
.Other extensions include:
Object Access with Basic
In Caché, classes are organized into packages, and class names include the package name followed by a period. For example, Sample.Person is a Person class of the Sample package.
The Basic New command is used to create an object. Basic has been extended with an OpenID command to access an existing object:
|
|
|
|
Here are some examples of code that access the person’s properties:
|
|
|
|
|
|
|
|
Database classes can be saved to disk with the Save method. For example:
person.Save()
will save the person, creating an object ID if it is the first time the object was stored. If related objects (such as the Employer) were also modified, they are automatically saved as well.
Java
Java is an increasingly popular programming technology, but connecting Java applications to a database can be challenging. Connecting to a relational database requires extensive coding of SQL – which is very time consuming and blunts many of the advantages of Java’s object technology. Direct object syntax to access the database is usually preferred, and some like the functionality of Enterprise Java Beans. Caché supports all of these approaches:
Object Access Through Projected Classes
Every Caché class can be projected as a Java (or EJB) class, with methods corresponding to every property and method of the Caché class. To Java programs these classes look just like any other local Java classes. The generated Java class uses a Java library provided by InterSystems to handle all communications between the client and server.
State for every Caché object is maintained in the Caché Application Server, although properties of the class are also cached in the client to optimize performance. Java method calls invoke corre-sponding methods on the Caché Application Server – including methods to store an object in the database and later retrieve it. It is transparent to the client as to which Caché Data Server contains the data, or even if the object data is stored in a relational database accessed through the Caché Application Server.
Caché Methods Written in Java
Methods of Caché classes can be written in Java using Caché Studio. However, unlike Caché ObjectScript and Basic, Java methods are not executed by the Caché Virtual Machine. Instead, they are included in the generated Java class and executed in any Java Virtual Machine. Such code is not accessible from non-Java methods.
Providing Persistence for J2EE Applications
Developers of J2EE applications, which use Enterprise Java Beans (EJB), work primarily with objects until such time as they need to access the database. Then they are usually forced to revert to using SQL. Through its JDBC interface, Caché can provide extremely fast SQL response to such applications. However, SQL access is not generally the preferred approach.
Object databases represent a more natural access technique to EJB program-mers. Caché projects Caché classes as EJBs, automatically generating high-performance persistence methods for Bean-Managed Persistence (BMP). This avoids the overhead of SQL and object/relational mapping – the result is higher scalability for J2EE applications.
High Performance Strategies with Java
Code in the Caché Virtual Machine usually executes faster than code in a Java Virtual Machine, and it is also usually much faster to develop. Although it is possible to build complete applications in Java, most clients obtain the best results by maximizing the amount of code they put in the Caché Application Server’s Scripting Languages (Basic and Caché ObjectScript) and limiting Java to the user interface portion of the application.
C++
Every Caché class can be projected as a C++ class, with methods correspond-ing to each property and method of the Caché class. To C++ programs, these classes look just like any other local C++ classes, and Caché automatically handles all communications between the client and server. Properties of the class are cached on the client, and C++ method calls invoke corresponding server side methods – including methods to store an object in the database and later retrieve it.
The Caché AdvantageFlexibility Java developers have choices when it comes to accessing Caché objects – they can use SQL and JDBC or more naturally project objects as Java classes or Enterprise Java Beans. High Performance All Java applica-tions, regardless of how they are connected to Caché, benefit from Caché’s superior performance and scalability. Native Compatibility with J2EE Means More Rapid Development Caché classes can easily be projected as EJBs, giving J2EE developers a simple way to connect to Caché’s post-relational database. When a Caché class is projected using bean-managed persistence, Caché auto-matically generates the method used by the EJB to access the Caché database. Because developers no longer have to hand code persistence methods, applications can be com-pleted more quickly. |
Caché and .NET
Because of its open and flexible data access, Caché works seamlessly with .NET. There are many ways of connecting the two, including objects, SQL, XML, and SOAP. Developers can create applications with the technologies they prefer – all of them will benefit from Caché’s superior performance and scalability.
COM & ADO
COM and ADO are both considered “older” Microsoft technologies, included in .NET to encourage migration to the newer framework. Caché interacts with COM – through its ObjectServer for ActiveX – exposing Caché classes as COM-compliant classes. In contrast, ADO provides object “wrappers” for relational data, and interacts with Caché via Caché’s relational data access.
ADO.NET
ADO.NET is a new incarnation of ADO, optimized for use in the .NET framework. It is intended to make .NET applications “database independent”. Like ADO, it uses Caché’s relational data access to interact with Caché.
Web Services
There are two ways of using Web services in .NET. One is to send XML documents over HTTP. The other is to use the SOAP protocol to simplify the exchange of XML documents. In both cases, because Caché can expose data as either XML or SOAP documents, it works seamlessly with .NET Web services.
The Caché AdvantageSpeedy Data Serving Web applications that use Caché as a data server benefit from the high performance and massive scalability provided by Caché’s multidimensional data engine. Productivity Developers will be more productive when they work with their favorite tools in environments that are familiar to them. Providing both SQL and object data access, Caché supports a wide variety of common development technologies and tools. Compatibility with .NET Caché fits easily into .NET architectures, giving developers the option of connecting to clients via Web services, XML, COM, or ODBC. |
Caché and XML
Just as HTML is an Internet-compatible mark-up language for displaying data, XML is a mark-up language for ex-changing data between applications. Using XML, disparate applications (within a company, or at different enterprises) can share data over a network. The structure of XML data is hierarchical and multidimensional, making it a natural match for Caché’s multidimensional data engine.
Caché provides an easy-to-use, bi-directional interface to XML that eliminates the need for developers to manually create a “mapping layer” of processing between XML data and the database.
Exporting XML
All that is required to make a Caché class compatible with XML is to have it inherit from the %XMLAdaptor class that is included in Caché. This provides all the methods needed to:
Importing XML
Caché comes with other classes that provide methods allowing developers to:
Caché and Web Services
Web Services enable the sharing of application functionality over the Internet as well as within an organization or system. Web Services have an interface described in WSDL (Web Service Defini-tion Language), and they return an XML document formatted according to the SOAP protocol.
Caché enables any class method, any SQL stored procedure, and any query to be automatically exposed as a Web service. Caché generates the WSDL descriptor for the service and, when the service is invoked, sends the response, appropriately formatted as SOAP/XML. Caché also facilitates rapid development by automatically generating a Web page to test the service, without the need to construct a client application.
The Caché AdvantageEasy Connectivity to XML Caché takes advantage of its capability for multiple inheritance to provide any Caché class a bi-directional interface to XML. The result: Caché classes can easily and quickly be turned into XML documents and schemas. Similarly, XML schemas and documents can be turned into Caché class definitions and objects. Rapid Development of Faster XML Applications Because Caché’s native multidimensional data structures are a good match to XML documents, there is no need for developers to manually code a “map” that translates between XML and the Caché database. Therefore, XML-enabled applications are quicker to develop. And with less processing overhead, they run faster, too. Instant Web Services Any Caché method can be published as a Web service with just a few clicks of a mouse. Caché automatically generates the WSDL descriptor and the SOAP response when the service is invoked. Existing Caché applications can easily be Web service enabled, and new Web service applications can be built extremely quickly. |
Integrating Caché with Other Technologies and Popular Tools
Caché can be used immediately with a wide variety of popular development tools and frameworks – virtually any that supports COM or .NET components, Java classes or EJB, SQL access via ODBC or JDBC, or development with XML and Web Services. As a result, Caché delivers unparalleled freedom of choice, enabling each developer to choose the most suitable development approach for each project.
Caché and Rational Rose
Caché RoseLink is an InterSystems-provided add-in to the popular Rational Rose object modeling tool. It provides a full round-trip engineering interface between Caché and Rational Rose, enabling schemas to be designed in Rational Rose and exported to Caché for implementation. Similarly, developers can import schemas from Caché into Rational Rose for further design or documentation.
Caché and Dreamweaver
Caché comes with an add-in to the Dreamweaver Web page design environment that gives Dreamweaver users an easy way of creating Caché Server Pages, and using Caché Application Tags.
The Caché AdvantageFreedom of Choice Caché allows programmers to use any development environment they choose for user interface and business logic programming. Through the use of projections, object servers, and gateways, Caché-based applications can interact with other programs using COM, .NET, C++, Java, EJB, and SQL. Links to Popular Tools Caché comes with special features that provide highly productive links to object modeling tools like Rational Rose and Web design tools like Dreamweaver. Developers who use these tools can very quickly create applications that tap into the power of Cach é’s post-relational database.
|
Caché Studio
Caché Studio is an easy-to-use and powerful integrated development environment that enables the rapid creation, debugging, and testing of Cach é applications. Notable features include:
Editors
Programmers can write Caché ObjectScript, Basic, and Java code as well as class definition files and Web pages. Clicking on a property, method, etc. in the editor displays the characteristics of that property, etc., and allows them to be edited in that display window.
Wizards
With just a few clicks developers can define or edit classes, Caché Server Pages, and SQL queries, publish Caché methods as Web services, and project Caché classes as Java, COM, or C++ classes, Enterprise Java Beans, and XML documents.
Automatic Syntax Checking
Improper syntax is automatically flagged for Caché ObjectScript, Basic, HTML, and Java.
“ View Web Page” Command
Developers can test Web pages directly from within the development environment.
Visual Debugger
Compile and debug code with a visual debugger, which can also attach to and debug an existing Caché process.
Context Sensitive Help
Caché Studio is fully integrated with its on-line documentation.
“ Import” and “Export”
Automatically import Caché class definitions from relational DDL schema definitions, or from object modeling tools. An Export tool allows creation of definition files to send to other computers.
The Caché AdvantageRapid Application Development The Caché Studio is a highly productive tool for creating, debugging, and testing Caché applications. Through the extensive use of wizards, Caché Studio eliminates much of the “drudge work ” associated with application development. |
Caché Technology Guide