UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'hh4GD2I5gR0Bs+OUHdFb5NRMZhXteBiDa45YAekyxFw=' 
WHERE 
  key_id = '1a21fc02067476cedb65830d86e71cb589f4ce21b77d47e158bb6e221789428d' 
  AND (
    token = 'hh4GD2I5gR0Bs+OUHdFb5NRMZhXteBiDa45YAekyxFw=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00053