Swedbank-SPP / swedbank-payment-portal

Swedbank Payment Portal API library for PHP
Other
36 stars 21 forks source link

Add possibility to use custom Cache #2

Closed jkanape closed 7 years ago

jkanape commented 7 years ago

Thanks for useful lib. I have suggestion for improvement: Current version uses Doctrine's FilesystemCache class for caching TransactionContainer. Storing serialized object in file system is not an option for projects which have many web servers for load balancing. If i understand correctly, to store it somewhere else (like database, memory...) the only option is to create and pass custom TransactionRepositoryFactory to ServiceOptions which would create custom TransactionRepository. Problem here is that this repository would have to manage not only storing and retrieving serialized object but also serialization/deserialization itself.

So it would be nice to have possibility to pass object which would be responsible only for storing and retrieving string.

Swedbank-SPP commented 7 years ago

Hello, sorry that this has taken so long, but your suggested feature is really needful and we added this support to 0.8.16 version. If there is a need to implement your custom persistence please implement Doctrine\Common\Cache\Cache interface and add that object to ServiceOptions as in this example:

new ServiceOptions(
     ...,
     new TransactionRepositoryFactory(new YourCustomCacheImplementation()) 
)

If cache is unspecified we'd use FilesystemCache (directory = SYS_TEMP_DIR + '/banklink') by default. Also there are many default Doctrine implementations under Doctrine\Common\Cache.

JanisE commented 4 years ago

I suggest you add this instruction to the README.md, it may be reaally useful.