UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'gMI4TCu94QX71yN3faR3qaswq+tybhgpUPp1vcmbcBI=' 
WHERE 
  key_id = '3ecb0db9325179295a4139717166a3938d828fc2f8602f48b51c638859080e09' 
  AND (
    token = 'gMI4TCu94QX71yN3faR3qaswq+tybhgpUPp1vcmbcBI=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00048