ooici/coi-services — pull request #782 by ifreecarve (2013-03-26 19:12:33+00:00)
Title: Added ability to cache predicates for in-memory lookup inside EnhancedResourceRegistryClient

This commit addresses the timeout error present in some extensive "launch platform agent" tests, caused by excessive calls to RR.find_subjects and RR.find_objects.

This has been fixed by adding capability the EnhancedResourceRegistryClient.

old way:
```python
# makes 2 calls to resource registry
RR2 = EnhancedResourceRegistryClient(self.clients.resource_registry)
models1 = self.RR2.find_objects("device1", PRED.hasModel, RT.InstrumentModel, True)
models2 = self.RR2.find_objects("device2", PRED.hasModel, RT.InstrumentModel, True)
```

new way:
```python
# makes 1 call to resource registry
RR2 = EnhancedResourceRegistryClient(self.clients.resource_registry)
RR2.cache_predicate(PRED.hasModel)
models1 = self.RR2.find_objects("device1", PRED.hasModel, RT.InstrumentModel, True)
models2 = self.RR2.find_objects("device2", PRED.hasModel, RT.InstrumentModel, True)
```

Note that no change is required to existing find_* calls.