UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'a5W1NS+2AV0AWDRwpQ9GtapRDvbxyHYlrFgkI7i0tl8=' 
WHERE 
  key_id = '1dc93e9195251eaf2e832e41926169758f75345058f2e5e78e9d3a82751a3040' 
  AND (
    token = 'a5W1NS+2AV0AWDRwpQ9GtapRDvbxyHYlrFgkI7i0tl8=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037