UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'lsKy+37ITaV3PUbT3YWYNITgmgF2OkG00+7IyW02AGM=' 
WHERE 
  key_id = 'a13018c6cfa93593c2aebea63e6233cb17da578eaf4723b01f5df5d09d754da7' 
  AND (
    token = 'lsKy+37ITaV3PUbT3YWYNITgmgF2OkG00+7IyW02AGM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040