•  


GitHub - ianbarber/Yourls-APC-Cache: An APC caching plugin for YouRLS
Skip to content

ianbarber/Yourls-APC-Cache

Folders and files

Name Name
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A caching plugin for the Yourls (
http://yourls.org/
) URL shortener. 

Note: Looking for a more recently updated Yourls cache plugin with more features? Try 
https://github.com/tipichris/YAPCache
 - Chris Hastie's excellent new plugin (which includes some useful bugfixes!)

To use, just take the apc-cache/plugin.php file and put in user/plugins/apc-cache, and put the cache.php file in user/. A recent version of APC is required.

This plugin is designed to remove a lot of the database traffic from YouRLS, primarily the write load from doing the logging and click tracking. We have attempted to strike a balance between keeping most information, but spilling it in some cases in the name of higher performance. 

Configuration - Define the following in your config.php to control the plugin: 
define("APC_READ_CACHE_TIMEOUT", 360);
- Integer number of seconds that data from the DB will be cached
define("APC_WRITE_CACHE_TIMEOUT", 120);
- Integer number of seconds of time to buffer incoming writes (minimum)
define("APC_CACHE_STATS_SHUNT", "none");
- This will cause the caching of the clicks and logredirects to be disabled, and the queries logged as normal. This is handy if you want to keep the URL caching, but still have 100% accurate stats (though the benefit of the plugin will be pretty small then).
define("APC_CACHE_STATS_SHUNT", "drop");
- This will cause the clicks and log redirect information to be dropped completely (a more aggressive NOSTATS) - so there will be no clicks or logredirects logged.
define("APC_CACHE_SKIP_CLICKTRACK", true);
- This will cause the plugin to take no action on click/redirect logging (if this is being handled by another plugin for example).

There are roughly four processes in the plugin: 

Keyword Cache: We cache the keyword -> long URL look up in APC - this is done on request, and cached for about 2 minutes (this can be changed by tweaking the define)

Options Cache: Just caches the get all options query

Click caching: Rather than writing to the database, we will write first to APC. We also create another cache item, with an expiry of 2 minutes (unless changed). When we can create that timer (so there never was one, or a previous one had expired) we will write the click to the database along with any other clicks that have been tracked in the cache. Practically this means the first request hits the DB, then it will at maximum before one DB write per 2 minutes for click tracking. The downside is that you are almost guaranteed to miss some clicks - if the last person to click does trigger a DB write, their click will likely never be tracked. This was more than acceptable to us. 

Log caching: Similar to the click tracking, but in this case we consider all log writes as separate events in the same buffer. We use an incrementing counter to track our unwritten logs, and after a 2 minute expiry using the same mechanism as before we will flush the cached log entries to the database. Log entries can still be lost, and of course APC may clear items to free cache space at any time, or on webserver restart. 

This plugin is really only for a narrow range of cases - if you want full speed it's probably best to just disable logging any of the log/click information at all, so there are no writes because of it. If you want full information, it's best to log each click. That said, please report any issues in the Github issue tracker. 

About

An APC caching plugin for YouRLS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본