Caché Programming Orientation Guide
Namespaces and Databases
[Back] [Next]
Go to:

This chapter describes how Caché organizes data and code. It discusses the following:

The chapter Useful Skills to Learn includes information on configuring namespaces, defining mappings, moving code and data, and so on.
Introduction to Namespaces and Databases
In Caché, any code runs in a namespace, which is a logical entity. A namespace provides access to data and to code, which is stored (typically) in multiple databases. A database is a file — a CACHE.DAT file. Caché provides a set of namespaces and databases for your use, and you can define additional ones.
In a namespace, the following options are available:
Mappings provide a convenient and powerful way to share data and code. Any given database can be used by multiple namespaces. For example, there are several system databases that all customer namespaces can access, as discussed later in this chapter.
You can change the configuration of a namespace after defining it, and Caché provides tools for moving code and data from one database to another. Thus you can reorganize your code and data during development, if you discover the need to do so. This makes it possible to reconfigure Caché applications (such as for scaling) with little effort.
Locks, Globals, and Namespaces
Because a global can be accessed from multiple namespaces, Caché provides automatic cross-namespace support for its locking mechanism. A lock on a given global applies automatically to all namespaces that use the database that stores the global.
For an introduction to locking, see Locking and Concurrency Control,” earlier in this book.
Database Basics
A Caché database is a CACHE.DAT file. You create a database via the Management Portal. Or if you have an existing Caché database, you can configure Caché to become aware of it.
Database Configuration
For any database, Caché requires the following configuration details:
Additional options include the following:
In most cases, you can create, delete, or modify database attributes while the system is running.
Database Features
With each database, Caché provides physical integrity guarantees for both the actual data and the metadata that organizes it. This integrity is guaranteed even if an error occurs during writes to the database.
The databases are automatically extended as needed, without manual intervention. If you expect a particular database to grow and you can determine how large it will become, you can “pre-expand” it by setting its initial size to be near the expected eventual size. If you do so, the performance is better.
Caché provides a number of strategies that allow high availability and recoverability. These include:
Caché has a technology for distributing data and application logic and processing among multiple systems. It is called the Enterprise Cache Protocol (ECP). On a multiserver system, a network of Caché database servers can be configured as a common resource, sharing data storage and application processing, with the data distributed seamlessly among them. This provides increased scalability as well as automatic failover and recovery.
Database Portability
Caché databases are portable across platforms and across versions, with the following caveats:
System-Supplied Databases
Caché provides the following databases:
For additional detail on CACHESYS and SAMPLES, see the chapter Assets and Resources in the Caché Security Administration Guide.
System-Supplied Namespaces
Caché provides the following namespaces for your direct use:
Caché uses other namespaces for its own purposes; see Configuring Namespaces in the Caché System Administration Guide.
Custom Items in CACHESYS
You can create items in the CACHESYS database. When you install a Caché upgrade, this database is upgraded. During this upgrade, some items are deleted unless they follow the naming conventions for custom items.
To add code or data to this database so that your items are not overwritten, do one of the following:
MAC code and include files are not affected by upgrade.
What Is Accessible in Your Namespaces
When you create a namespace, Caché automatically defines mappings for that namespace. As a result, in that namespace, you can use the following items (provided you are logged in as a user with suitable permissions for these items):
Via extended global references, your code can access globals that are defined in other namespaces. For information, see Global Structure in Using Caché Globals.
The Caché security model controls which data and which code any user can access; see the chapter Caché Security for an introduction.
System Globals in Your Namespaces
Your namespaces contain additional system globals, which fall into two rough categories:
In most cases, you should not manually write to or delete any of these globals. See Global Naming Conventions,” in Using Caché Globals.
Stream Directory
In any given namespace, when you create a file stream, Caché writes a file to a default directory and then later deletes it.
This is important because your users will need write access to this directory; if not, your code will not be able to create file streams.
The default directory is the stream subdirectory of the global database for this namespace.
For More Information
For more information on the topics covered in this chapter, see the following: