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

Query time 0.00046