I am observing a similar behaviour using python socket.gethostbyname() on mac and on an AWS Lambda function. On Mac the resolved address is cached for 15 seconds. AWS Lambda respects the record TTL and caches the address for 2-4 seconds.
Apparently mDNSresponder respect the TTL but has a minimum time of 15sec