UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'NdSgbKVp0nFYOc7bsILfhJJbGScMul54dakLniyO1PM=' 
WHERE 
  key_id = '6e263e76a4c5aedb053502058abf3ff1dea7554185774e59e71997b78587da55' 
  AND (
    token = 'NdSgbKVp0nFYOc7bsILfhJJbGScMul54dakLniyO1PM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053