Reading the blue book at page 152, we can find this:
[A repository] provide methods to add and remove objects, which will encapsulate the actual insertion or removal of data in the data store. Provide methods that select objects based on some criteria and return fully instantiated objects or collections of objects whose attribute values meet the criteria, thereby encapsulating the actual storage and query technology.
One of advantages in repositories introduction is that:
They allow easy substitution of a dummy implementation, for use in testing
Crystal clear! I can use an interface to define the repository; implement it with many classes (i.e. real database, rather than in-memory value for testing); inject one implementation or another using DI engine.
On the other hand:
The hexagonal architecture (aka ports and adapters) divides a system into several loosely-coupled interchangeable components, such as the application core, the database, the user interface, test scripts and interfaces with other systems.
To me it look like extend the repository concepts not only to a database. Do I have a notification port? Then I will implement two adapters one for RabbitMQ, another one for Amazon SNS or in-memory topic.
Put in this way, to me: a repository could be considered an adapter for the database port.
Am I missing something?