# Managing Collections

As with any data source, the maintenance requirements of a Verity collection are dictated by the amount, frequency, and type of changes that occur in the records. You can run maintenance routines directly from either the CFCOLLECTION or CFINDEX tags or via the Administrator Verity page. For more information on this topic, see the Allaire Knowledge Base article, "Maintaining Collections" (ID# 1080) on our Web site at http://www.allaire.com/Support/KnowledgeBase/SearchForm.cfm.

The easiest way to perform collection management tasks is to create a ColdFusion template that runs the operations, then add the task on the Administrator Scheduler page. The page presents a wide range of scheduling options.

## Maintenance options

Choose an option based on the following function descriptions.

- Repair -- Runs internal Verity routines to fix corrupted records. If you suspect a collection has become corrupted, it is probably safest to re-populate it.
- Optimize -- Packs the indexed data for better performance. This is similar to database optimization. This procedure can be used as part of routine maintenance. The Optimize action is deprecated for CFINDEX except to maintain legacy code; the CFCOLLECTION tag is recommended instead. For more information on this command, see the Allaire Knowledge Base article, "How To Optimize Your Verity Collection" (ID# 416) on our Web site at http://www.allaire.com/Support/KnowledgeBase/SearchForm.cfm.
- Purge -- Removes all data from a collection.
- Delete (when used as a CFINDEX ACTION) -- Deletes the specified KEY value, or comma-separated values, from the collection.
- Delete (when used on the Administrator Verity page or in CFCOLLECTION) -- Deletes the entire collection.
- Update -- Re-populates the collection with changed records and new records and adds a key if one is not part of the collection. This operation does not delete records that have been deleted from the data source. To update a collection from the Administrator Verity main page, select a collection on the list, click Index, then click Update on the index page.
- Refresh (CFINDEX ACTION only) -- Deletes all data and re-populates the collection.

## Securing a collection

A couple of possible scenarios for restricting access to a Verity collection are:

- The ColdFusion Administrator may need to specify developer access to collections.
- A public site may need to limit user access to collections.

| To restrict access to a collection, follow these steps:

1. Open the Advanced Server Security page of the ColdFusion Administrator and click the Use Advanced Server Security box.
2. Click the Security Contexts button.
3. Enter a name for the secured collection and click Add.
4. Optionally enter a description for the secured collection.
5. Click Collections on the Enable Security for Resource Types list.
6. Click Apply.

You can then develop an appropriate authentication interface to allow access to the secured collection.