UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'O/STNlpYsci6Dsh5JmhmIziytMwPnWgcng3ConNMANQ=' 
WHERE 
  key_id = '697c447d858629165792ea7ff70678c33acd33eed1e8b456ab1acbff1a7f5711' 
  AND (
    token = 'O/STNlpYsci6Dsh5JmhmIziytMwPnWgcng3ConNMANQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00055