UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'l+Agy+uCyoJJrLWv3cO8Myz1AKWxk9JctSV6nyEtVbU=' 
WHERE 
  key_id = '24816bcd4cac8bf8539732ad1185248fe508003765b0b66566bee6dfd4cab545' 
  AND (
    token = 'l+Agy+uCyoJJrLWv3cO8Myz1AKWxk9JctSV6nyEtVbU=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027