Answer the question
In order to leave comments, you need to log in
Interface vs Provider, is there a difference in the implementation of the functionality described below?
Let's take the caching class as an example.
We need to write functionality for several caching engines (Redis, File, SQLite).
On the one hand, you can write a CacheProvider that describes common methods for caching (get, set) and connects the necessary "drivers" through named constructors.
This is how I see it being used:
$cache= CacheProvider::redis(array $cfg) //@return Redis instance
//Или
$cache = CacheProvider::driver(string CacheProvider::DRIVER_REDIS, array $cfg);
$cache = new RedisCache(array $cfg);
I don't see any disadvantages in this method yet. If they are still there, open my eyes. Googled Interface vs Provider But did not find a clear one.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question