matthiasmullie / scrapbook

PHP cache library, with adapters for e.g. Memcached, Redis, Couchbase, APC(u), SQL and additional capabilities (e.g. transactions, stampede protection) built on top.
https://www.scrapbook.cash
MIT License
315 stars 27 forks source link

Postgres set on conflict update #24

Closed AlexKomrakov closed 7 years ago

AlexKomrakov commented 7 years ago

Since version 9.5 postgres (9.6 latest) has on conflict update set syntax. This syntax avoids lots of error record in postgres logs (duplicate key error). https://www.postgresql.org/docs/9.5/static/sql-insert.html

codecov-io commented 7 years ago

Codecov Report

Merging #24 into master will decrease coverage by 0.24%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #24      +/-   ##
==========================================
- Coverage    84.1%   83.86%   -0.25%     
==========================================
  Files          44       44              
  Lines        2737     2751      +14     
==========================================
+ Hits         2302     2307       +5     
- Misses        435      444       +9
Impacted Files Coverage Δ
src/Adapters/PostgreSQL.php 77.5% <100%> (+12.11%) :arrow_up:
src/Adapters/SQL.php 90.78% <0%> (-3.23%) :arrow_down:
src/Adapters/Memcached.php 70.46% <0%> (-0.68%) :arrow_down:
src/Adapters/Couchbase.php 87.41% <0%> (-0.67%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e1546f8...92e880a. Read the comment docs.

matthiasmullie commented 7 years ago

Thanks for this PR!

You wouldn't happen to know offhand if there's an easy (and not too intensive/slow) way to detect the PostgreSQL version? Or a fallback alternative for older versions? I also want to keep this working for older PostgreSQL versions where possible.

If not, I can look into it later - just a bit swamped now :)

matthiasmullie commented 7 years ago

This has been merged (https://github.com/matthiasmullie/scrapbook/commit/ee7f2f440030cc1034fea47df5022d2de0617ed1) - thanks!