If you have a CacheIndex but not a PrimaryKey (perhaps you used -trace with the evaluator rather than -cdebug All), you can search the cache's GraphLog to find the PrimaryKey.

The GraphLog is mostly used during weeding, but it can be useful when picking apart the cache too. It contains an entry for each cache entry with certain key pieces of information. You can get a printed representation of it with the PrintGraphLog utility. Here's a sample of its output:

  Node: pk = 4d28ba275bd7cd24 5cc9cf0103e42be9, ci = 1, ...
  Node: pk = ec6361d61d032a6b 29312a8f3ac688ea, ci = 2, ...
  Node: pk = b97934ad0e8f5845 551f0482be0ab312, ci = 3, ...
  Node: pk = d8e6dd3e6d5ea5d1 bf54afed8db26f60, ci = 4, ...
...
  Node: pk = 653cb0ad674031ee 8386cae36494f626, ci = 23617, ...
  Node: pk = 37521d2332efb30b 9851a95e96b02f51, ci = 23618, ...
  Node: pk = d92cb1e94ea9917c 51f3d8dc0de43b1f, ci = 23621, ...
  Root: pkgFP = 0a6bc76f4a651fc6 ec968a6e5a0587bb, model = 2662186712, ...
  Root: pkgFP = b22a63222329629a 1f05cf70f5555a74, model = 3220122452, ...
  Root: pkgFP = b22a63222329629a 1f05cf70f5555a74, model = 3220122452, ...
  Root: pkgFP = b22a63222329629a 1f05cf70f5555a74, model = 3220122452, ...
*** Totals ***
  roots = 618
  nodes = 77936

The "Node" entries are the ones that correspond to cache entries. (The "Root" entries correspond to builds performed in the past rather than individual cache entries.)

If we want to find the PrimaryKey of CacheIndex 1234, we can just put the output of PrintGraphLog through grep:

% PrintGraphLog | grep 'ci = 1234,'
  Node: pk = 17973c765efe206e 982e987fd2796a69, ci = 1234, ...

Note the comma after "1234". If we left that off we might get more than we wanted:

% PrintGraphLog | grep 'ci = 1234'
  Node: pk = 17973c765efe206e 982e987fd2796a69, ci = 1234, ...
  Node: pk = 0fadde8e2eb8fd31 5d90f7d801f26685, ci = 12340, ...
  Node: pk = a970ffdefb8bf876 f39c0625e7166674, ci = 12341, ...
...
  Node: pk = 68563a1b7f4fdf61 b4a3ed095623a9e9, ci = 123404, ...
  Node: pk = 32c8c984b7286d1e 9d7b0d3c23e2f2b9, ci = 123405, ...
  Node: pk = 8080709d20b00cfc 28811a892713b980, ci = 123406, ...
...