User Tools

Site Tools

Translations of this page:

Sidebar

Documentation index

new_rotation_faq

This is an old revision of the document!


New Rotation FAQ

Rotation - Groups shows that I have 10 galleries while Rotation - List thumbs - 20

Each gallery can be assigned to more then 1 group. You can notice it while gallery edit: there are 2 select fields for groups - main and ext. Rotation - groups counts using main group so we can see real amount of galleries in DB, while Rotation - list thumbs shows galleries using Ext groups , the way you'll see it on site.

Thumbs (Galleries) are not getting deleted

  • up to update 46 there was a problem with deletion of large parts of thumb, script was not able to delete lat's say 1000 thumb during 30 seconds browser timeout time.
  • that's why since update 46 thumbs won't be actually deleted once you press 'Delete', instead those thumbs will be marked as 'Marked for deletion' and once every 10 minutes cron script will check for those thumbs and actually delete it.
  • you want to force that action you have to run following command in SSG
  • cd /PATH_TO_/scj/bin/; env HTTP_HOST=yourdomain.com php rot.php process_deleted=true 
  • there's one exclusion - if you delete thumbs in 'List Thumbs' and total amount of thumbs being deleted is less then 30.

What is cache

Script does not generate static page each minute or something like that. Instead it creates a page once someone request it and saves it to cache with expiration time = CACHE_TIME, so each next the same request will get this page from cache till expiration time.

Yo can set CACHE_TIME in Rotation - Settings , but if for some reason you want to overwrite it somewhere - you can add in common.php

if (!defined('CACHE_TIME')) define('CACHE_TIME', 900);

If you want a page without cache - add &skip_cache=true to any request for example http://domain.com/?skip_cache=true. Note that this request will only show a page to you and will NOT save this page to cache.

If you want script to recreate a page AND save it to cache - you have to go to Rotation - Special - Recreate visited pages and it will add a cookie to your browser so each page you visit will be recreated and saved to cache.

For example: A page was created at 0 seconds. Cache time = 1000 seconds.

At 200th second you change design. If you or any other surfer open that page at this time - you will not see new design.

If you open with 'skip_cache' - you'll see new design, surfers - not.

If you open with 'Recreate cookie' - you'll see new design and surfers will see new design.

Cache Engines (New)

The main idea of cache is generate a page once and then show it to every visitor until cache expires. So we need a place to store cache data

Regular Files Usually (bu default) we store cache in file (scj/cache - file cache). Pros - works everywhere, no need to setup anything. Cons - file cache means a lot of files on disk, and it's slow.

Memcached

Pros: easy to setup, easy to manage. Cons: you lose all your cache data when server reboots or memcache is restarted. So each time after that you'll need some time to “warm up” cache ie create pages.

Also unless you have more then one instance of memcached - all your cache data will be stored within one instance and if you click at “clean cache” at one site , this will kill cache for all sites.

That's why there are a couple of new cache engines

The easiest one to migrate to is Couchbase CouchBase - it's a successor of MemBase (inspired by memcached I believe)

The main advantage of it is that you don't have to do a lot to start using it.

  1. Ask admin to install couchbase
  2. add the same strings as for memcache
$config['memcached_host'] = '127.0.0.1';
$config['memcached_port'] = '11211';

that's it.

Redis - another great solution written from scratch.

  1. ask admin to install redis
  2. ask admin to install redis extension for php
  3. add to includes/config.php
$config['redis_host'] = '127.0.0.1';
$config['redis_port'] = '6379';
$config['redis_database'] = 0; 
$config['redis_password'] = '';

if your admin prefers to use sockets then 

$config['redis_host'] = '/tmp/redis.sock';
$config['redis_port'] = '0';

That's it.

How to add a big list of thumbs

If you have really big list to import it could be really hard due to some reasons like size of POST is usually limited, server won't have enough time to process it and so on. Beside that adding a lot of galleries really fast may overload your server.

Good idea is load load this list smoothly using import sets. You have to

  • create and upload file cut.php
<?php

error_reporting(E_ALL & ~E_NOTICE);

if (!$_GET['file']) die("\n You have to pass file=... parameter in URL");
if (!file_exists($_GET['file'])) die("\n File {$_GET['file']} does NOT exists. Check path. ");
if (!is_writeable($_GET['file'])) die("\n File {$_GET['file']} is NOT writeable. Set 666 permissions. ");

if (!file_exists('./tmp.file') or !is_writeable('./tmp.file')) die("\n File tmp.file does not exists OR is NOT writeable. Set 666 permissions. ");

echo passthru("head -n500 {$_GET['file']} ");
if (!$_GET['test']) exec("tail -n +500 {$_GET['file']} > tmp.file; cp tmp.file {$_GET['file']} ");
  • upload to the same location your dump and set permissions 666
  • Upload empty file tmp.file and also set permissions 666
  • Click Test and select fields
  • cut.php outputs 500 lines and cuts dump by those 500 lines. This way you'll add everything as usual import set - gradually and smoothly.
  • &test=true means do not cut dump by 500 lines this time. You have to remove this parameter after test. So your final URL will be http://yourdomain/path_to/cut.php?file=DUMP_NAME

That's it.

Cache Engines (New)

If you read New Rotation FAQ you should know that script generates a page on request only. We do not generate million of pages by cron or something like that. When the page is generated we have to store if somewhere in cache. But we have different types of cache you can use.

File cache A basic one. All cached pages are stored in files (scj/cache folder) Pros - works everywhere, you don't have to do anything. Cons - it's a file cache, it's slow, not so good cached by OS disk operation and script has to check all files for expiration date and so on.

Memcached it was a big step ahead some time ago. Pros: everybody know it. There's no proble for admin to setup it. Cons: sometimes it's hard to find out how much memory is actually still free, data gets fragmented, if you reboot server - you lose all cached data and need time to “warm up” cache after reboot. Memcache can not segregate cached data by popularity and stores everything in memory. It's really painful to reset cache just for 1 site for example.

That's why there are some other cache engines you worth using

New cache engines (basically NoSQL dbs) deliver you more performance while consuming less CPU and HDD.

Easiest solution - Couchbase which was built on MemBase, based on memcachedb, which was inspired memcached. It's really easy to start using it

  1. ask admin to setup CouchBase
  2. add 2 lines to scj/includes/config.php
$config['memcached_host'] = '127.0.0.1';
$config['memcached_port'] = '11211';

and that's it. You can use it with versions 48-49 too.

Redis - another nice key-value product . To you it you have to

  1. ask admin to setup Redis
  2. ask admin to add redis module for php
  3. add following to scj/includes/config.php
$config['redis_host'] = '127.0.0.1';
$config['redis_port'] = '6379';
$config['redis_database'] = 0; 
$config['redis_password'] = '';

There are few new lines. redis_password - if you have a dedicated server most likely you don't want to setup it. redis_database - it's kinda number of slot in redis DB. Useful if you want to separate caches for your sites for some reason.

Any of those 2 new engines are better then memcache and definitely better then file cache. I'd recommend to use file cache in emergency case only.

new_rotation_faq.1458669181.txt.gz · Last modified: 2016/03/22 17:53 (external edit)