Open Swader opened 8 years ago
With the PHP array cache you could throw in a constructor that gives it an initial array to start with.
Then you could have this array dumped to a PHP file (var_export). This way you'd also leverage the benefits of the opcache and not need to do any additional parsing.
Hmm, good idea, that. It would change the interface signature for the cache constructor, though, no? Would this be an okay change? Or would this skip the interface and apply only to the array cache?
Constructors (how the object is made) shouldn't feature on an interface (how the object behaves).
Do you plan on adding other cache options? I'd say make this an option in the configuration of 'ArrayCache' in the same way that server details would be an option for 'RedisCache'.
Wanting to actively warm up the cache is a requirement you probably only want with an array cache anyway - as you lose everything once the PHP instance dies (unlike with an external cache that could stay alive).
You could even change it to file cache and make the constructor accept a file path.
On construction you would then load the PHP array in the file and you could hook the destruct method to save any changes.
Constructors (how the object is made) shouldn't feature on an interface (how the object behaves).
Quite right :+1:
Do you plan on adding other cache options?
Yeah, eventually, but focusing on the interface and the array one for now, that's enough for current needs.
Wanting to actively warm up the cache is a requirement you probably only want with an array cache anyway
Is it, though? I'd want to feed things into a Redis or whatever other cache, too, especially in heavy apps like Symfony.
On construction you would then load the PHP array in the file and you could hook the destruct method to save any changes.
Sounds good. Think you could whip up a PR with that?
Wanting to actively warm up the cache is a requirement you probably only want with an array cache anyway
Is it, though? I'd want to feed things into a Redis or whatever other cache, too, especially in heavy apps like Symfony.
Sounds like we have two different issues here.
FileCache
that is persistent between PHP instances.I can sort you out a PR for the FileCache
over the weekend (out tonight and Saturday).
Cool, I'll see if I don't do it first, thanks
There should be an option to fill the cache / Rauth instance with pre-parsed or pre-configured values, so that it doesn't have to parse things on every call.
Several configuration formats could supported, but I don't care much for YAML and similar. I'd much rather have:
For the purpose of separation of concerns, it would probably be better not to feed through Rauth, but I feel weird about feeding Cache directly, too. Something else entirely?