UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'KOASRyafiHlwTT4vsnrAdwdN2bhrNdyCdI21ubNiMEg=' 
WHERE 
  key_id = '331a1e730e348e1a0a5f0cb187c66f267c9619dc63243b161a18f326b9b35288' 
  AND (
    token = 'KOASRyafiHlwTT4vsnrAdwdN2bhrNdyCdI21ubNiMEg=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00034