Implement a custom caching mechanism with a specific eviction policy, explaining the time and space complexity of your approach.