UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Xjiv+peb4463K7BnAXLfS4tG9AQzoOF+MHu1rgzfoaA=' 
WHERE 
  key_id = '3904900ef76da13d3a177e590f124cf3917a3f62d0d64e96ff7a780473275349' 
  AND (
    token = 'Xjiv+peb4463K7BnAXLfS4tG9AQzoOF+MHu1rgzfoaA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034