I'm trying to use Cake's native caching methodes to cache some data that I will need to paginate, sort andfiler (search) - that's why I'm caching data arrays, not views or paginated arrays/views. As far as I can see searching/filtering components and Paginator only ask the database, which is what I don't want. Is there any way I could put these together in Cake? Thanks in advance for any answer.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You're correct to assume that Cake always expects a database result to paginate. One of the easiest solutions is refactoring a class like this one into a helper (for the pagination) or a component (for filtering) and feed the helper/component your data arrays (more info on custom helpers and components). The only downside to this is that your application has to read the cached arrays into memory before creating a paginated result set.
There's also this article, but I'm not sure if applies to your setup.
Another option might be to write your own datasource for cached data arrays, but Cake's documentation on this is a little meagre. I've dabbled in the creation of a datasource for some custom XML feeds, but never got around to adding pagination. From the third-party datasources floating around I'm not sure if it's even possible.