UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'hScP2W2jc0rm0cN1BYweCEqkshKwkfQqfevOozmvKvs=' 
WHERE 
  key_id = 'f7df21c7775089b7d8796134e535ef32abc426f2a24a26ece476cd3a9a078ac6' 
  AND (
    token = 'hScP2W2jc0rm0cN1BYweCEqkshKwkfQqfevOozmvKvs=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053