UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'TmsakBNgtDNKHScM+S7CnuTd40dD8O/z+gXAhXv/SfY=' 
WHERE 
  key_id = 'c51556dbf1a27573231ba1cea7779bbd71d7f97c1ec0031801b892bab8919999' 
  AND (
    token = 'TmsakBNgtDNKHScM+S7CnuTd40dD8O/z+gXAhXv/SfY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00028