UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'x54cMlHzAmUUElvNolTNxhh2k9/DiC/lzY3fAyW2lOU=' 
WHERE 
  key_id = '87c7bd950aa405e6cfd8025ba95d83d307b31ac385230f3af99959b599cb0792' 
  AND (
    token = 'x54cMlHzAmUUElvNolTNxhh2k9/DiC/lzY3fAyW2lOU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044