[SOLVED] CB Gallery Module - Cached random order?

6 years 11 months ago - 6 years 1 month ago #293007 by sysopcrew
I've got the module working to show 7 random gallery images from profile.%, but the images do not change unless I change the Limit on the Media tab in the module setting. It seems to generate a new random selection only when it's saved with new settings.



Is there a cache?

Version 2.0.1

--
David Riviera
Attachments:

Please Log in to join the conversation.

6 years 11 months ago #293042 by krileon
Replied by krileon on topic CB Gallery Module - Cached random order?
Yes, the random order value is cached per gallery. There's already a feature ticket to review improving this.

forge.joomlapolis.com/issues/6250


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: sysopcrew

Please Log in to join the conversation.

6 years 11 months ago #293045 by sysopcrew
Replied by sysopcrew on topic CB Gallery Module - Cached random order?
One thing I've done is cache the directory build/database call every 15 minutes into a stored array, then use array_rand(), shuffle($array) or array[rand(0,count($array)-1)] to pick a key until the cache expires. You aren't reading the disk or database every time, but get pretty decent random display. Creating an item in the gallery could trigger the array cache, even. Just some ideas. At least I'm not crazy thinking it was misconfigured. Thanks!

--
David Riviera

Please Log in to join the conversation.

6 years 11 months ago #293062 by krileon
Replied by krileon on topic CB Gallery Module - Cached random order?
The galleries are cached into session and pass from page to page using the gallery id generated from the galleries parameters. The random value is basically just the id. The big issue is it needs to have the same random seed when moving from Page 1 to Page 2 for example (otherwise paging literally can't work with random usage). This means it needs to cache with the gallery or be passed with the pagination link. Passing with pagination link only means when you edit an entry and hit cancel it returns to the wrong seed if you're on page 1 since it'll generate a new seed. This means return URLs then need to have it. It was easier to just cache it with the gallery initially and improve it later.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 1 month ago #302149 by ichepurnoy
Replied by ichepurnoy on topic CB Gallery Module - Cached random order?
To show 1 random image (from users' uploads) in a module, I went to module's settings , and set Media \ Paging \ OrderBy to `random`.
In the `Gallery` tab there, I've set `asset` option to `profile.%`. Done!
Just stating this for anyone who might be stuck on this.

Please Log in to join the conversation.

6 years 1 month ago - 6 years 1 month ago #302150 by sysopcrew
Replied by sysopcrew on topic CB Gallery Module - Cached random order?
Yes, random now works because of a fix krileon put in forge.joomlapolis.com/issues/6250 six months ago.

--
David Riviera
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.246 seconds

Facebook Twitter LinkedIn