Command CacheThis example shows how to use a private database to store Mathematica commands and query the data from Java and Mathematica. The example code is loaded from the Examples subdirectory of DatabaseLink. If you find that the examples in this section do not work as shown, you may need to install or restore the example database with the DatabaseExamples` package. The command cache allows you to store Mathematica expression as typeset box expressions data in a database. StoreCommand is used to store the boxes in the database.
| Out[2]= |  |
The data can then be retrieved from the database using CommandCache[].
| Out[3]= |  |
Several attributes of each command are stored in the database. Each command is given an ID, generated when it is stored. The expression is stored as a string formatted with FullForm; this allows it to be reused within Mathematica. In addition, an image of the expression is saved as well as the time at which the data was stored. GetCommandAttributes can be used to get the attribute names, these can be used to filter the data returned.
| Out[4]= |  |
| Out[5]= |  |
A filter can also be used with the database. The following example finds all results that contain Power.
| Out[6]= |  |
| Out[7]= |  |
| Out[8]= |  |
A command can also be retrieved using its ID.
| Out[9]= |  |
Another feature of this package is a Java GUI that you can use to browse the data. It provides functionality for managing the data and pasting the data into notebook.
| Out[10]= |  |
The GUI is automatically updated when new commands are added to the database. Likewise, the GUI is automatically updated when commands are removed. ClearCommandCache can be used to remove all the data in the command cache.
| Out[12]= |  |
|